Skip to content

Commit

Permalink
Stackless issue python#222: fix main-tasklet termination with serial …
Browse files Browse the repository at this point in the history
…mismatch

Fix the termination of a main-tasklet when serial_last_jump !=
initial_stub.serial. This caused an assertion failure and a reference
leak.
  • Loading branch information
Anselm Kruis committed Jun 21, 2019
1 parent 4f7b3ec commit 0b8da63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Stackless/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ What's New in Stackless 3.X.X?

*Release date: 20XX-XX-XX*

- https://github.com/stackless-dev/stackless/issues/221
Fix a bug that could cause an assertion failure and a reference leak during
the termination of a main-tasklet, if an application embeds Stackless Python.

- https://github.com/stackless-dev/stackless/issues/221
Change the width of C-stack serial numbers to 64bit. This prevents overflows
in long running applications with an embedded Stackless Python.
Expand Down
9 changes: 7 additions & 2 deletions Stackless/module/scheduling.c
Original file line number Diff line number Diff line change
Expand Up @@ -1441,8 +1441,13 @@ slp_tasklet_end(PyObject *retval)
* the original stub if necessary. (Meanwhile, task->cstate may be an old nesting state and not
* the original stub, so we take the stub from the tstate)
*/
if (ts->st.serial_last_jump != ts->st.initial_stub->serial)
slp_transfer_return(ts->st.initial_stub);
if (ts->st.serial_last_jump != ts->st.initial_stub->serial) {
Py_DECREF(retval);
SLP_STORE_NEXT_FRAME(ts, NULL);
slp_transfer_return(ts->st.initial_stub); /* does not return */
assert(0);
return NULL;
}
}

/* remove current from runnables. We now own its reference. */
Expand Down

0 comments on commit 0b8da63

Please sign in to comment.