summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-06-04 09:58:49 (GMT)
committerGitHub <noreply@github.com>2024-06-04 09:58:49 (GMT)
commite3e7607167a9de2790a07a1a5f76a825f551bc9a (patch)
tree6ff7e0334ab2adab22f2267377c088a60800a751
parent3bf7a5079c8d1845af98c145056e7ae1e102be43 (diff)
downloadcpython-e3e7607167a9de2790a07a1a5f76a825f551bc9a.zip
cpython-e3e7607167a9de2790a07a1a5f76a825f551bc9a.tar.gz
cpython-e3e7607167a9de2790a07a1a5f76a825f551bc9a.tar.bz2
[3.12] gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021) (#120023)
gh-111499: Fix PYTHONMALLOCSTATS at Python exit (#120021) Call _PyObject_DebugMallocStats() earlier in Py_FinalizeEx(), before the interpreter is deleted. (cherry picked from commit 5a1205b641df133932ed4c65b9a4ff5724e89963)
-rw-r--r--Python/pylifecycle.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index a0130fd..2c36527 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1969,6 +1969,13 @@ Py_FinalizeEx(void)
// XXX Ensure finalizer errors are handled properly.
finalize_interp_clear(tstate);
+
+#ifdef WITH_PYMALLOC
+ if (malloc_stats) {
+ _PyObject_DebugMallocStats(stderr);
+ }
+#endif
+
finalize_interp_delete(tstate->interp);
#ifdef Py_REF_DEBUG
@@ -1994,11 +2001,6 @@ Py_FinalizeEx(void)
fclose(dump_refs_fp);
}
#endif /* Py_TRACE_REFS */
-#ifdef WITH_PYMALLOC
- if (malloc_stats) {
- _PyObject_DebugMallocStats(stderr);
- }
-#endif
call_ll_exitfuncs(runtime);