bpo-38070: visit_decref() calls _PyObject_IsFreed() (GH-15782)

In debug mode, visit_decref() now calls _PyObject_IsFreed() to ensure
that the object is not freed. If it's freed, the program fails with
an assertion error and Python dumps informations about the freed
object.
This commit is contained in:
Victor Stinner 2019-09-09 17:44:59 +02:00 committed by GitHub
parent 3cbc23aa22
commit d91d4de317
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -376,6 +376,8 @@ static int
visit_decref(PyObject *op, void *data)
{
assert(op != NULL);
_PyObject_ASSERT(op, !_PyObject_IsFreed(op));
if (PyObject_IS_GC(op)) {
PyGC_Head *gc = AS_GC(op);
/* We're only interested in gc_refs for objects in the