Skip to content

Commit dc8df6e

Browse files
authored
GH-113595: Don't enter invalid executor (GH-113596)
1 parent 5dc79e3 commit dc8df6e

File tree

2 files changed

+39
-19
lines changed

2 files changed

+39
-19
lines changed

Python/bytecodes.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,17 +2364,27 @@ dummy_func(
23642364

23652365
PyCodeObject *code = _PyFrame_GetCode(frame);
23662366
_PyExecutorObject *executor = (_PyExecutorObject *)code->co_executors->executors[oparg&255];
2367-
Py_INCREF(executor);
2368-
if (executor->execute == _PyUOpExecute) {
2369-
current_executor = (_PyUOpExecutorObject *)executor;
2370-
GOTO_TIER_TWO();
2367+
if (executor->vm_data.valid) {
2368+
Py_INCREF(executor);
2369+
if (executor->execute == _PyUOpExecute) {
2370+
current_executor = (_PyUOpExecutorObject *)executor;
2371+
GOTO_TIER_TWO();
2372+
}
2373+
next_instr = executor->execute(executor, frame, stack_pointer);
2374+
frame = tstate->current_frame;
2375+
if (next_instr == NULL) {
2376+
goto resume_with_error;
2377+
}
2378+
stack_pointer = _PyFrame_GetStackPointer(frame);
23712379
}
2372-
next_instr = executor->execute(executor, frame, stack_pointer);
2373-
frame = tstate->current_frame;
2374-
if (next_instr == NULL) {
2375-
goto resume_with_error;
2380+
else {
2381+
opcode = this_instr->op.code = executor->vm_data.opcode;
2382+
this_instr->op.arg = executor->vm_data.oparg;
2383+
oparg = (oparg & (~255)) | executor->vm_data.oparg;
2384+
code->co_executors->executors[oparg&255] = NULL;
2385+
Py_DECREF(executor);
2386+
DISPATCH_GOTO();
23762387
}
2377-
stack_pointer = _PyFrame_GetStackPointer(frame);
23782388
}
23792389

23802390
replaced op(_POP_JUMP_IF_FALSE, (cond -- )) {

Python/generated_cases.c.h

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

0 commit comments

Comments
 (0)