bpo-38070: visit_decref() calls _PyObject_IsFreed() (GH-15782) · python/cpython@5731172 (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Commit 5731172

miss-islingtonvstinner

and

authored

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. (cherry picked from commit d91d4de) Co-authored-by: Victor Stinner vstinner@redhat.com

File tree

1 file changed

lines changed

1 file changed

lines changed

Original file line number Diff line number Diff line change
@@ -376,6 +376,8 @@ static int
376 376 visit_decref(PyObject *op, void *data)
377 377 {
378 378 assert(op != NULL);
379 +_PyObject_ASSERT(op, !_PyObject_IsFreed(op));
380 +
379 381 if (PyObject_IS_GC(op)) {
380 382 PyGC_Head *gc = AS_GC(op);
381 383 /* We're only interested in gc_refs for objects in the