Skip to content

Commit

Permalink
Stackless issue python#133: fix Python/ceval.c
Browse files Browse the repository at this point in the history
Always track frames. Otherwise Stackless leaks frames.
  • Loading branch information
Anselm Kruis committed Oct 31, 2017
1 parent da8a841 commit cfd51a5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -4615,6 +4615,12 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
* when the generator is resumed. */
Py_CLEAR(f->f_back);

#ifdef STACKLESS
/* Stackless calls need GC. */
assert(!_PyObject_GC_IS_TRACKED(f));
_PyObject_GC_TRACK(f);
#endif

/* Create a new generator that owns the ready to run frame
* and return that as the value. */
if (is_coro) {
Expand Down Expand Up @@ -4642,6 +4648,8 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
if (stackless) {
Py_INCREF(Py_None);
retval = Py_None;
assert(!_PyObject_GC_IS_TRACKED(f));
_PyObject_GC_TRACK(f);
SLP_STORE_NEXT_FRAME(tstate, f);
Py_DECREF(f);
return STACKLESS_PACK(tstate, retval);
Expand All @@ -4659,8 +4667,6 @@ _PyEval_EvalCodeWithName(PyObject *_co, PyObject *globals, PyObject *locals,
else {
retval = slp_eval_frame(f);
}
Py_DECREF(f);
return retval;
}
#else
retval = PyEval_EvalFrameEx(f,0);
Expand Down Expand Up @@ -5455,6 +5461,8 @@ _PyFunction_FastCall(PyCodeObject *co, PyObject **args, Py_ssize_t nargs,
if (stackless) {
Py_INCREF(Py_None);
result = Py_None;
assert(!_PyObject_GC_IS_TRACKED(f));
_PyObject_GC_TRACK(f);
SLP_STORE_NEXT_FRAME(tstate, f);
Py_DECREF(f);
return STACKLESS_PACK(tstate, result);
Expand Down

0 comments on commit cfd51a5

Please sign in to comment.