8000 Delay subinterpreter finalization to after tracemalloc · emmatyping/cpython@029241e · GitHub
[go: up one dir, main page]

Skip to content

Commit 029241e

Browse files
committed
Delay subinterpreter finalization to after tracemalloc
1 parent 2fd09b0 commit 029241e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Python/pylifecycle.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2124,9 +2124,6 @@ _Py_Finalize(_PyRuntimeState *runtime)
21242124
_PyImport_FiniExternal(tstate->interp);
21252125
finalize_modules(tstate);
21262126

2127-
/* Clean up any lingering subinterpreters. */
2128-
finalize_subinterpreters();
9216
2129-
21302127
/* Print debug stats if any */
21312128
_PyEval_Fini();
21322129

@@ -2158,6 +2155,11 @@ _Py_Finalize(_PyRuntimeState *runtime)
21582155
so it is possible to use tracemalloc in objects destructor. */
21592156
_PyTraceMalloc_Fini();
21602157

2158+
/* Clean up any lingering subinterpreters. It is important this happens
2159+
AFTER tracemalloc finalizes, as tracemalloc may hold references to
2160+
frame data in other interpreters. */
2161+
finalize_subinterpreters();
2162+
21612163
/* Finalize any remaining import state */
21622164
// XXX Move these up to where finalize_modules() is currently.
21632165
_PyImport_FiniCore(tstate->interp);

0 commit comments

Comments
 (0)
0