summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2024-01-03 11:01:13 (GMT)
committerGitHub <noreply@github.com>2024-01-03 11:01:13 (GMT)
commitdc8df6e84024b79aa96e85a64f354bf8e827bcba (patch)
tree38792b5dcfd086197b8b352b08376dc261dbad2a
parent5dc79e3d7f26a6a871a89ce3efc9f1bcee7bb447 (diff)
downloadcpython-dc8df6e84024b79aa96e85a64f354bf8e827bcba.zip
cpython-dc8df6e84024b79aa96e85a64f354bf8e827bcba.tar.gz
cpython-dc8df6e84024b79aa96e85a64f354bf8e827bcba.tar.bz2
GH-113595: Don't enter invalid executor (GH-113596)
-rw-r--r--Python/bytecodes.c28
-rw-r--r--Python/generated_cases.c.h30
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();
}