]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021)
authorVictor Stinner <vstinner@python.org>
Tue, 4 Jun 2024 09:39:07 +0000 (11:39 +0200)
committerGitHub <noreply@github.com>
Tue, 4 Jun 2024 09:39:07 +0000 (11:39 +0200)
Call _PyObject_DebugMallocStats() earlier in Py_FinalizeEx(), before
the interpreter is deleted.

Python/pylifecycle.c

index 67bbbd01ca0c482e073968332bf8cfb8265e337e..cbdf5c1b771fffc3c505bfc5f057b649a3de816c 100644 (file)
@@ -2119,6 +2119,12 @@ Py_FinalizeEx(void)
     }
 #endif /* Py_TRACE_REFS */
 
+#ifdef WITH_PYMALLOC
+    if (malloc_stats) {
+        _PyObject_DebugMallocStats(stderr);
+    }
+#endif
+
     finalize_interp_delete(tstate->interp);
 
 #ifdef Py_REF_DEBUG
@@ -2129,12 +2135,6 @@ Py_FinalizeEx(void)
 #endif
     _Py_FinalizeAllocatedBlocks(runtime);
 
-#ifdef WITH_PYMALLOC
-    if (malloc_stats) {
-        _PyObject_DebugMallocStats(stderr);
-    }
-#endif
-
     call_ll_exitfuncs(runtime);
 
     _PyRuntime_Finalize();