Skip to content

Commit b8829fb

Browse files
committed
Stackless issue python#290: add an assert()
Before dropping the GIL, assert that non-Vectorcall functions did reset _PyStackless_TRY_STACKLESS.
1 parent 07f90b0 commit b8829fb

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎Python/ceval_gil.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ static void recreate_gil(struct _gil_runtime_state *gil)
144144
static void
145145
drop_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate)
146146
{
147+
#ifdef STACKLESS
148+
/* 1: a non vectorcall function did not reset _PyStackless_TRY_STACKLESS */
149+
assert(1 != _PyStackless_TRY_STACKLESS);
147150
/*
148151
* The flag _PyStackless_TRY_STACKLESS is shared between threads
149152
* and interpreters. If a function, that does not support the
@@ -152,6 +155,7 @@ drop_gil(struct _ceval_runtime_state *ceval, PyThreadState *tstate)
152155
* to other threads. To prevent this, it is reset here.
153156
*/
154157
STACKLESS_RETRACT();
158+
#endif
155159
struct _gil_runtime_state *gil = &ceval->gil;
156160
if (!_Py_atomic_load_relaxed(&gil->locked)) {
157161
Py_FatalError("drop_gil: GIL is not locked");

0 commit comments

Comments
 (0)