Skip to content

Commit 1303cf0

Browse files
Protect against re-entrant tracer calls
1 parent cc48bf0 commit 1303cf0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Python/optimizer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ _PyOptimizer_Optimize(
138138
// return immediately without optimization.
139139
return 0;
140140
}
141+
if (_tstate->jit_tracer_state.initial_state.func == NULL) {
142+
// gh-143123: It is possible for another function to finalize the current
143+
// tracer's state while tracing. This might happen in a
144+
// Python -> C -> Python call.
145+
return 0;
146+
}
141147
assert(!interp->compiling);
142148
assert(_tstate->jit_tracer_state.initial_state.stack_depth >= 0);
143149
#ifndef Py_GIL_DISABLED

0 commit comments

Comments
 (0)