Skip to content

Commit af696ea

Browse files
committed
Free cold executor after final GC
1 parent 142bab6 commit af696ea

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Python/pystate.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -773,11 +773,6 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
773773
Py_CLEAR(interp->monitoring_callables[t][e]);
774774
}
775775
}
776-
struct _PyExecutorObject *cold = interp->cold_executor;
777-
if (cold != NULL) {
778-
interp->cold_executor = NULL;
779-
_PyExecutor_Free(cold);
780-
}
781776
interp->sys_profile_initialized = false;
782777
interp->sys_trace_initialized = false;
783778
for (int t = 0; t < PY_MONITORING_TOOL_IDS; t++) {
@@ -820,7 +815,11 @@ interpreter_clear(PyInterpreterState *interp, PyThreadState *tstate)
820815
/* Last garbage collection on this interpreter */
821816
_PyGC_CollectNoFail(tstate);
822817
_PyGC_Fini(interp);
823-
818+
struct _PyExecutorObject *cold = interp->cold_executor;
819+
if (cold != NULL) {
820+
interp->cold_executor = NULL;
821+
_PyExecutor_Free(cold);
822+
}
824823
/* We don't clear sysdict and builtins until the end of this function.
825824
Because clearing other attributes can execute arbitrary Python code
826825
which requires sysdict and builtins. */

0 commit comments

Comments
 (0)