]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-125703: Correctly honour tracemalloc hooks on specialized DECREF paths (#125704)
authorPablo Galindo Salgado <Pablogsal@gmail.com>
Fri, 18 Oct 2024 16:09:34 +0000 (17:09 +0100)
committerGitHub <noreply@github.com>
Fri, 18 Oct 2024 16:09:34 +0000 (17:09 +0100)
Include/internal/pycore_object.h
Misc/NEWS.d/next/Core_and_Builtins/2024-10-18-16-00-10.gh-issue-125703.QRoqMo.rst [new file with mode: 0644]

index ad1a7d7e120519c2cbbf0a2e51082ca6d15fb105..96f6d61e1c620b25fa02f50187d1e913ef98c83d 100644 (file)
@@ -208,6 +208,11 @@ _Py_DECREF_SPECIALIZED(PyObject *op, const destructor destruct)
 #ifdef Py_TRACE_REFS
         _Py_ForgetReference(op);
 #endif
+        struct _reftracer_runtime_state *tracer = &_PyRuntime.ref_tracer;
+        if (tracer->tracer_func != NULL) {
+            void* data = tracer->tracer_data;
+            tracer->tracer_func(op, PyRefTracer_DESTROY, data);
+        }
         destruct(op);
     }
 }
diff --git a/Misc/NEWS.d/next/Core_and_Builtins/2024-10-18-16-00-10.gh-issue-125703.QRoqMo.rst b/Misc/NEWS.d/next/Core_and_Builtins/2024-10-18-16-00-10.gh-issue-125703.QRoqMo.rst
new file mode 100644 (file)
index 0000000..7cbfa72
--- /dev/null
@@ -0,0 +1,2 @@
+Correctly honour :mod:`tracemalloc` hooks in specialized ``Py_DECREF``
+paths. Patch by Pablo Galindo