Skip to content

Commit 2e5e9e6

Browse files
fix infinite deopt involving monitoring
1 parent 55cf943 commit 2e5e9e6

3 files changed

Lines changed: 12 additions & 30 deletions

File tree

Python/bytecodes.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,7 +3051,9 @@ dummy_func(
30513051
/* If the eval breaker is set then stay in tier 1.
30523052
* This avoids any potentially infinite loops
30533053
* involving _RESUME_CHECK */
3054-
if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
3054+
uintptr_t eval_breaker = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker);
3055+
int dont_enter = !(tstate->tracing || eval_breaker == FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version));
3056+
if (dont_enter || _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) {
30553057
opcode = executor->vm_data.opcode;
30563058
oparg = (oparg & ~255) | executor->vm_data.oparg;
30573059
next_instr = this_instr;
@@ -5376,15 +5378,15 @@ dummy_func(
53765378
}
53775379

53785380
/* Progress is guaranteed if we DEOPT on the eval breaker, because
5379-
* ENTER_EXECUTOR will not re-enter tier 2 with the eval breaker set. */
5381+
* ENTER_EXECUTOR will not re-enter tier 2 wiFth the eval breaker set. */
53805382
tier2 op(_TIER2_RESUME_CHECK, (--)) {
53815383
#if defined(__EMSCRIPTEN__)
53825384
HANDLE_PENDING_AND_DEOPT_IF(_Py_emscripten_signal_clock == 0);
53835385
_Py_emscripten_signal_clock -= Py_EMSCRIPTEN_SIGNAL_HANDLING;
53845386
#endif
53855387
uintptr_t eval_breaker = _Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker);
53865388
HANDLE_PENDING_AND_DEOPT_IF(eval_breaker & _PY_EVAL_EVENTS_MASK);
5387-
HANDLE_PENDING_AND_DEOPT_IF(!(tstate->tracing || eval_breaker == FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version)));
5389+
assert(tstate->tracing || eval_breaker == FT_ATOMIC_LOAD_UINTPTR_ACQUIRE(_PyFrame_GetCode(frame)->_co_instrumentation_version));
53885390
}
53895391

53905392
tier2 op(_COLD_EXIT, ( -- )) {

Python/executor_cases.c.h

Lines changed: 4 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)