[Python-checkins] bpo-38070: visit_decref() calls _PyObject_IsFreed() (GH-15782)

Miss Islington (bot) webhook-mailer at python.org
Mon Sep 9 13:18:13 EDT 2019


https://github.com/python/cpython/commit/5731172bb1e958b1d80b18eaf88d3f2f93cfccdd
commit: 5731172bb1e958b1d80b18eaf88d3f2f93cfccdd
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-09-09T10:18:09-07:00
summary:

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 at redhat.com>

files:
M Modules/gcmodule.c

diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 2741edc0a021..b2ee56623cd4 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



More information about the Python-checkins mailing list