[issue43962] test_interpreters: when TestInterpreterAttrs.test_id_type() is run alone, it fails with an assertion error

STINNER Victor report at bugs.python.org
Wed Apr 28 07:05:17 EDT 2021


STINNER Victor <vstinner at python.org> added the comment:

Creating an _interpreters.InterpreterID object calls newinterpid() which calls _PyInterpreterState_IDIncref(interp).

_PyInterpreterState_IDIncref(interp) does nothing if interp->id_mutex is NULL.

Calling _interpreters.get_current() calls interp_get_current() which calls _PyInterpreterState_IDInitref().

_PyInterpreterState_IDInitref() creates the id_mutex and initializes id_refcount to 0.

Later, when the _interpreters.InterpreterID object is deallocated, interpid_dealloc() calls _PyInterpreterState_IDDecref(). Since id_mutex was created in the meanwhile, _PyInterpreterState_IDDecref() now decrements id_refcnt.

... It doesn't work: _PyInterpreterState_IDIncref() should always increase the reference count.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43962>
_______________________________________


More information about the Python-bugs-list mailing list