You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stable ABI doesn't work with PySide (Shiboken) on Python 3.12 #118997
PyObject_GetAttrString() leaves PyType_Type.tp_bases.ob_refcnt unchanged since it's an immortal tuple, and the code runs on Python 3.12 which is aware of immortal object.
Py_DECREF(bases) decrements PyType_Type.tp_bases.ob_refcnt since the code is built with Python 3.9 and Py_DECREF() is inlined.
The problem occurs at Python exit, when static types are cleared by _PyStaticType_Dealloc(). The following code is executed:
/* _Py_ClearImmortal() should only be used during runtime finalization. */staticinlinevoid_Py_ClearImmortal(PyObject*op)
{
if (op) {
assert(op->ob_refcnt==_Py_IMMORTAL_REFCNT);
op->ob_refcnt=1;
Py_DECREF(op);
}
}
#define_Py_ClearImmortal(op) \
do { \
_Py_ClearImmortal(_PyObject_CAST(op)); \
op = NULL; \
} while (0)
The condition assert(op->ob_refcnt == _Py_IMMORTAL_REFCNT); is false.
IMO _Py_ClearImmortal() should use _Py_IsImmortal() in the assertion instead, as clear_tp_bases() does.
Activity
pythongh-118997: Fix _Py_ClearImmortal() assertion
hroncok commentedon May 13, 2024
Does this not happen on 3.13+ as well?
vstinner commentedon May 13, 2024
3.13 uses
_Py_IsImmortal()and so is not affected.[3.12] gh-118997: Fix _Py_ClearImmortal() assertion (#119001)
ericsnowcurrently commentedon May 21, 2024
Thanks for fixing this, @vstinner.