diff options
author | Mark Shannon <mark@hotpy.org> | 2024-05-02 12:10:31 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 12:10:31 (GMT) |
commit | 67bba9dd0f5b9c2d24c2bc6d239c4502040484af (patch) | |
tree | efb9ef5019f26b24ffa722fe817a954c3eea0ce8 /Python/generated_cases.c.h | |
parent | f8e088df2a87f613ee23ea4f6787f87d9196b9de (diff) | |
download | cpython-67bba9dd0f5b9c2d24c2bc6d239c4502040484af.zip cpython-67bba9dd0f5b9c2d24c2bc6d239c4502040484af.tar.gz cpython-67bba9dd0f5b9c2d24c2bc6d239c4502040484af.tar.bz2 |
GH-117442: Check eval-breaker at start (rather than end) of tier 2 loops (GH-118482)
Diffstat (limited to 'Python/generated_cases.c.h')
-rw-r--r-- | Python/generated_cases.c.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index 32b485e..2a0f268 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -2493,19 +2493,21 @@ next_instr += 1; INSTRUCTION_STATS(ENTER_EXECUTOR); #ifdef _Py_TIER2 - int prevoparg = oparg; - CHECK_EVAL_BREAKER(); - if (this_instr->op.code != ENTER_EXECUTOR || - this_instr->op.arg != prevoparg) { - next_instr = this_instr; - DISPATCH(); - } PyCodeObject *code = _PyFrame_GetCode(frame); _PyExecutorObject *executor = code->co_executors->executors[oparg & 255]; assert(executor->vm_data.index == INSTR_OFFSET() - 1); assert(executor->vm_data.code == code); assert(executor->vm_data.valid); assert(tstate->previous_executor == NULL); + /* If the eval breaker is set then stay in tier 1. + * This avoids any potentially infinite loops + * involving _RESUME_CHECK */ + if (_Py_atomic_load_uintptr_relaxed(&tstate->eval_breaker) & _PY_EVAL_EVENTS_MASK) { + opcode = executor->vm_data.opcode; + oparg = (oparg & ~255) | executor->vm_data.oparg; + next_instr = this_instr; + DISPATCH_GOTO(); + } tstate->previous_executor = Py_None; Py_INCREF(executor); GOTO_TIER_TWO(executor); |