File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff 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 ();
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 );
You can’t perform that action at this time.
0 commit comments