diff options
author | Mark Shannon <mark@hotpy.org> | 2024-01-03 11:01:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-03 11:01:13 (GMT) |
commit | dc8df6e84024b79aa96e85a64f354bf8e827bcba (patch) | |
tree | 38792b5dcfd086197b8b352b08376dc261dbad2a | |
parent | 5dc79e3d7f26a6a871a89ce3efc9f1bcee7bb447 (diff) | |
download | cpython-dc8df6e84024b79aa96e85a64f354bf8e827bcba.zip cpython-dc8df6e84024b79aa96e85a64f354bf8e827bcba.tar.gz cpython-dc8df6e84024b79aa96e85a64f354bf8e827bcba.tar.bz2 |
GH-113595: Don't enter invalid executor (GH-113596)
-rw-r--r-- | Python/bytecodes.c | 28 | ||||
-rw-r--r-- | Python/generated_cases.c.h | 30 |
2 files changed, 39 insertions, 19 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 29e1dab..2eeeac5 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -2364,17 +2364,27 @@ dummy_func( PyCodeObject *code = _PyFrame_GetCode(frame); _PyExecutorObject *executor = (_PyExecutorObject *)code->co_executors->executors[oparg&255]; - Py_INCREF(executor); - if (executor->execute == _PyUOpExecute) { - current_executor = (_PyUOpExecutorObject *)executor; - GOTO_TIER_TWO(); + if (executor->vm_data.valid) { + Py_INCREF(executor); + if (executor->execute == _PyUOpExecute) { + current_executor = (_PyUOpExecutorObject *)executor; + GOTO_TIER_TWO(); + } + next_instr = executor->execute(executor, frame, stack_pointer); + frame = tstate->current_frame; + if (next_instr == NULL) { + goto resume_with_error; + } + stack_pointer = _PyFrame_GetStackPointer(frame); } - next_instr = executor->execute(executor, frame, stack_pointer); - frame = tstate->current_frame; - if (next_instr == NULL) { - goto resume_with_error; + else { + opcode = this_instr->op.code = executor->vm_data.opcode; + this_instr->op.arg = executor->vm_data.oparg; + oparg = (oparg & (~255)) | executor->vm_data.oparg; + code->co_executors->executors[oparg&255] = NULL; + Py_DECREF(executor); + DISPATCH_GOTO(); } - stack_pointer = _PyFrame_GetStackPointer(frame); } replaced op(_POP_JUMP_IF_FALSE, (cond -- )) { diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h index ce31967..99fd169 100644 --- a/Python/generated_cases.c.h +++ b/Python/generated_cases.c.h @@ -2371,24 +2371,34 @@ } TARGET(ENTER_EXECUTOR) { - frame->instr_ptr = next_instr; + _Py_CODEUNIT *this_instr = frame->instr_ptr = next_instr; next_instr += 1; INSTRUCTION_STATS(ENTER_EXECUTOR); TIER_ONE_ONLY CHECK_EVAL_BREAKER(); PyCodeObject *code = _PyFrame_GetCode(frame); _PyExecutorObject *executor = (_PyExecutorObject *)code->co_executors->executors[oparg&255]; - Py_INCREF(executor); - if (executor->execute == _PyUOpExecute) { - current_executor = (_PyUOpExecutorObject *)executor; - GOTO_TIER_TWO(); + if (executor->vm_data.valid) { + Py_INCREF(executor); + if (executor->execute == _PyUOpExecute) { + current_executor = (_PyUOpExecutorObject *)executor; + GOTO_TIER_TWO(); + } + next_instr = executor->execute(executor, frame, stack_pointer); + frame = tstate->current_frame; + if (next_instr == NULL) { + goto resume_with_error; + } + stack_pointer = _PyFrame_GetStackPointer(frame); } - next_instr = executor->execute(executor, frame, stack_pointer); - frame = tstate->current_frame; - if (next_instr == NULL) { - goto resume_with_error; + else { + opcode = this_instr->op.code = executor->vm_data.opcode; + this_instr->op.arg = executor->vm_data.oparg; + oparg = (oparg & (~255)) | executor->vm_data.oparg; + code->co_executors->executors[oparg&255] = NULL; + Py_DECREF(executor); + DISPATCH_GOTO(); } - stack_pointer = _PyFrame_GetStackPointer(frame); DISPATCH(); } |