Skip to content

Commit

Permalink
[3.11] pythongh-96049: frame->prev_instr incorrect state
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-pytel committed Aug 17, 2022
1 parent 2bb363c commit f513a07
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -1714,7 +1714,10 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
} \
assert(_PyInterpreterFrame_LASTI(frame) >= -1); \
/* Jump back to the last instruction executed... */ \
next_instr = frame->prev_instr + 1; \
if (frame->prev_instr >= first_instr) \
next_instr = frame->prev_instr + 1 + _PyOpcode_Caches[_PyOpcode_Deopt[_Py_OPCODE(*frame->prev_instr)]]; \
else \
next_instr = first_instr; \
stack_pointer = _PyFrame_GetStackPointer(frame); \
/* Set stackdepth to -1. \
Update when returning or calling trace function. \
Expand Down Expand Up @@ -2273,8 +2276,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
new_frame->localsplus[i] = NULL;
}
_PyFrame_SetStackPointer(frame, stack_pointer);
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
frame->prev_instr = next_instr - 1;
JUMPBY(INLINE_CACHE_ENTRIES_BINARY_SUBSCR);
new_frame->previous = frame;
frame = cframe.current_frame = new_frame;
CALL_STAT_INC(inlined_py_calls);
Expand Down Expand Up @@ -4758,8 +4761,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
goto error;
}
_PyFrame_SetStackPointer(frame, stack_pointer);
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
frame->prev_instr = next_instr - 1;
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
new_frame->previous = frame;
cframe.current_frame = frame = new_frame;
CALL_STAT_INC(inlined_py_calls);
Expand Down Expand Up @@ -4865,8 +4868,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
}
STACK_SHRINK(2-is_meth);
_PyFrame_SetStackPointer(frame, stack_pointer);
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
frame->prev_instr = next_instr - 1;
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
new_frame->previous = frame;
frame = cframe.current_frame = new_frame;
goto start_frame;
Expand Down Expand Up @@ -4907,8 +4910,8 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
}
STACK_SHRINK(2-is_meth);
_PyFrame_SetStackPointer(frame, stack_pointer);
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
frame->prev_instr = next_instr - 1;
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
new_frame->previous = frame;
frame = cframe.current_frame = new_frame;
goto start_frame;
Expand Down

0 comments on commit f513a07

Please sign in to comment.