Skip to content

Commit

Permalink
Stackless issue python#133: fix Python/ceval.c
Browse files Browse the repository at this point in the history
Ensure, that frame->f_lasti is >= -1. This invariant was broken by the
switch to wordcode.
  • Loading branch information
Anselm Kruis committed Oct 29, 2017
1 parent 3a234aa commit 7fe8f02
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -3887,9 +3887,12 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
*/
f->f_stacktop = stack_pointer;

/* the -1 is to adjust for the f_lasti change.
(look for the word 'Promise' above) */
f->f_lasti = INSTR_OFFSET() - 2;
/* Set f->f_lasti to the instruction before the current one or to the
* first instruction (-1). See "f->f_lasti refers to ..." above.
*/
f->f_lasti = INSTR_OFFSET() ?
assert(INSTR_OFFSET() >= sizeof(_Py_CODEUNIT)),
(int)(INSTR_OFFSET() - sizeof(_Py_CODEUNIT)) : -1;
if (SLP_PEEK_NEXT_FRAME(tstate)->f_back != f)
return retval;
STACKLESS_UNPACK(tstate, retval);
Expand Down Expand Up @@ -3935,9 +3938,12 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
f->f_execute = slp_eval_frame_noval;
f->f_stacktop = stack_pointer;

/* the -1 is to adjust for the f_lasti change.
(look for the word 'Promise' above) */
f->f_lasti = INSTR_OFFSET() - 2;
/* Set f->f_lasti to the instruction before the current one or to the
* first instruction (-1). See "f->f_lasti refers to ..." above.
*/
f->f_lasti = INSTR_OFFSET() ?
assert(INSTR_OFFSET() >= sizeof(_Py_CODEUNIT)),
(int)(INSTR_OFFSET() - sizeof(_Py_CODEUNIT)) : -1;
return (PyObject *) Py_UnwindToken;
#endif
}
Expand Down

0 comments on commit 7fe8f02

Please sign in to comment.