GH-103488: Use return-offset, not yield-offset. (GH-103502)

* Use return-offset, not yield-offset, so that instruction pointer is correct when sending to a generator or coroutine.
This commit is contained in:
Mark Shannon 2023-04-13 16:19:07 +01:00 committed by GitHub
parent 4307feaddc
commit efb8a2553c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 455 additions and 414 deletions

View file

@ -672,7 +672,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
_PyCode_CODE(tstate->interp->interpreter_trampoline);
entry_frame.stacktop = 0;
entry_frame.owner = FRAME_OWNED_BY_CSTACK;
entry_frame.yield_offset = 0;
entry_frame.return_offset = 0;
/* Push frame */
entry_frame.previous = prev_cframe->current_frame;
frame->previous = &entry_frame;
@ -881,6 +881,7 @@ exit_unwind:
_PyInterpreterFrame *dying = frame;
frame = cframe.current_frame = dying->previous;
_PyEvalFrameClearAndPop(tstate, dying);
frame->return_offset = 0;
if (frame == &entry_frame) {
/* Restore previous cframe and exit */
tstate->cframe = cframe.previous;