Skip to content

Commit

Permalink
Stackless issue python#149: Fix exc state handling during tasklet dea…
Browse files Browse the repository at this point in the history
…llocation

Fix a few incorrect assertions introduced by commit 245a802.
A test in the upcoming commit for Stackless issue python#190 triggered an
assertion failure.
  • Loading branch information
Anselm Kruis committed Dec 29, 2018
1 parent 0d490e1 commit cb1c4ea
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Stackless/module/taskletobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,13 @@ tasklet_clear(PyTaskletObject *t)
Py_CLEAR(t->exc_state.exc_value);
Py_CLEAR(t->exc_state.exc_traceback);

/* The stack of exception states should contain just this tasklet. */
assert(t->exc_info->previous_item == NULL);
if (Py_VerboseFlag && t->exc_info != &t->exc_state) {
fprintf(stderr,
"PyTaskletObject_Clear: warning: tasklet still has a generator\n");
}
/* Assert that the tasklet is at the end of the chain. */
assert(t->exc_state.previous_item == NULL);
/* Unlink the exc_info chain. There is no guarantee, that
* the object t->exc_info points to still exists, because
* the order of calls to tp_clear is undefined.
*/
t->exc_info = &t->exc_state;
}

/*
Expand Down Expand Up @@ -281,8 +282,13 @@ tasklet_dealloc(PyTaskletObject *t)
}
Py_DECREF(t->tempval);
Py_XDECREF(t->def_globals);
/* Assert that the tasklet is at the end of the chain. */
assert(t->exc_state.previous_item == NULL);
assert(t->exc_info == &t->exc_state);
/* Unlink the exc_info chain. There is no guarantee, that
* the object t->exc_info points to still exists, because
* the order of calls to tp_clear is undefined.
*/
t->exc_info = &t->exc_state;
exc_state_clear(&t->exc_state);
Py_TYPE(t)->tp_free((PyObject*)t);
}
Expand Down

0 comments on commit cb1c4ea

Please sign in to comment.