GH-113595: Don't enter invalid executor (GH-113596)

This commit is contained in:
Mark Shannon 2024-01-03 11:01:13 +00:00 committed by GitHub
parent 5dc79e3d7f
commit dc8df6e840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 19 deletions

View File

@ -2364,6 +2364,7 @@ dummy_func(
PyCodeObject *code = _PyFrame_GetCode(frame);
_PyExecutorObject *executor = (_PyExecutorObject *)code->co_executors->executors[oparg&255];
if (executor->vm_data.valid) {
Py_INCREF(executor);
if (executor->execute == _PyUOpExecute) {
current_executor = (_PyUOpExecutorObject *)executor;
@ -2376,6 +2377,15 @@ dummy_func(
}
stack_pointer = _PyFrame_GetStackPointer(frame);
}
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();
}
}
replaced op(_POP_JUMP_IF_FALSE, (cond -- )) {
assert(PyBool_Check(cond));

View File

@ -2371,13 +2371,14 @@
}
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];
if (executor->vm_data.valid) {
Py_INCREF(executor);
if (executor->execute == _PyUOpExecute) {
current_executor = (_PyUOpExecutorObject *)executor;
@ -2389,6 +2390,15 @@
goto resume_with_error;
}
stack_pointer = _PyFrame_GetStackPointer(frame);
}
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();
}
DISPATCH();
}