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)
2124
2124
_PyImport_FiniExternal (tstate -> interp );
2125
2125
finalize_modules (tstate );
2126
2126
2127
- /* Clean up any lingering subinterpreters. */
2128
- finalize_subinterpreters ();
9216
2129
-
2130
2127
/* Print debug stats if any */
2131
2128
_PyEval_Fini ();
2132
2129
@@ -2158,6 +2155,11 @@ _Py_Finalize(_PyRuntimeState *runtime)
2158
2155
so it is possible to use tracemalloc in objects destructor. */
2159
2156
_PyTraceMalloc_Fini ();
2160
2157
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
+
2161
2163
/* Finalize any remaining import state */
2162
2164
// XXX Move these up to where finalize_modules() is currently.
2163
2165
_PyImport_FiniCore (tstate -> interp );
You can’t perform that action at this time.
0 commit comments