diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-09-09 15:44:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-09 15:44:59 (GMT) |
commit | d91d4de31745fc1ed4c7e6c208917827c9c472b6 (patch) | |
tree | 70d189bf69d41e7fe873e1b0b7293a80f0e26dd4 /Modules/gcmodule.c | |
parent | 3cbc23aa229bc5ec04845053df78eae5f54e0497 (diff) | |
download | cpython-d91d4de31745fc1ed4c7e6c208917827c9c472b6.zip cpython-d91d4de31745fc1ed4c7e6c208917827c9c472b6.tar.gz cpython-d91d4de31745fc1ed4c7e6c208917827c9c472b6.tar.bz2 |
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.
Diffstat (limited to 'Modules/gcmodule.c')
-rw-r--r-- | Modules/gcmodule.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 134f6d1..f6e841d 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -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 |