summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-09 17:18:09 (GMT)
committerGitHub <noreply@github.com>2019-09-09 17:18:09 (GMT)
commit5731172bb1e958b1d80b18eaf88d3f2f93cfccdd (patch)
tree3998d4a401925467e51d8395871a55ae07f5ac66 /Modules
parent2d5594fac21a81a06f82c3605318dfa96e72398f (diff)
downloadcpython-5731172bb1e958b1d80b18eaf88d3f2f93cfccdd.zip
cpython-5731172bb1e958b1d80b18eaf88d3f2f93cfccdd.tar.gz
cpython-5731172bb1e958b1d80b18eaf88d3f2f93cfccdd.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. (cherry picked from commit d91d4de31745fc1ed4c7e6c208917827c9c472b6) Co-authored-by: Victor Stinner <vstinner@redhat.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/gcmodule.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 2741edc..b2ee566 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