Skip to content

Commit 05cee5d

Browse files
committed
pythongh-107265: Fix _PyFrame_OpAlreadyRan for ENTER_EXECUTOR case
1 parent 102685c commit 05cee5d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Objects/frameobject.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,13 +1090,27 @@ static int
10901090
_PyFrame_OpAlreadyRan(_PyInterpreterFrame *frame, int opcode, int oparg)
10911091
{
10921092
// This only works when opcode is a non-quickened form:
1093+
assert(opcode != ENTER_EXECUTOR);
10931094
assert(_PyOpcode_Deopt[opcode] == opcode);
10941095
int check_oparg = 0;
1096+
PyCodeObject *code = _PyFrame_GetCode(frame);
10951097
for (_Py_CODEUNIT *instruction = _PyCode_CODE(_PyFrame_GetCode(frame));
10961098
instruction < frame->instr_ptr; instruction++)
10971099
{
1098-
int check_opcode = _PyOpcode_Deopt[instruction->op.code];
1099-
check_oparg |= instruction->op.arg;
1100+
int check_opcode = -1;
1101+
if (instruction->op.code == ENTER_EXECUTOR) {
1102+
int exec_index = instruction->op.arg;
1103+
_PyExecutorObject *exec = code->co_executors->executors[exec_index];
1104+
check_opcode = exec->vm_data.opcode;
1105+
check_oparg |= exec->vm_data.oparg;
1106+
}
1107+
else {
1108+
check_opcode = _PyOpcode_Deopt[instruction->op.code];
1109+
check_oparg |= instruction->op.arg;
1110+
}
1111+
1112+
assert(check_opcode != ENTER_EXECUTOR);
1113+
11001114
if (check_opcode == opcode && check_oparg == oparg) {
11011115
return 1;
11021116
}

0 commit comments

Comments
 (0)