diff options
author | Victor Stinner <vstinner@python.org> | 2023-09-08 11:10:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-08 11:10:33 (GMT) |
commit | b55cf2c2d82d7567720df113117752841ce74606 (patch) | |
tree | 5a68b820cd77c21d9d5db9a4a1cfe49b309eccf0 /Python/ceval_gil.h | |
parent | 9dd28d2da941160abf0b5f54b1e7e3a7ef4465fb (diff) | |
download | cpython-b55cf2c2d82d7567720df113117752841ce74606.zip cpython-b55cf2c2d82d7567720df113117752841ce74606.tar.gz cpython-b55cf2c2d82d7567720df113117752841ce74606.tar.bz2 |
[3.11] gh-104690: thread_run() checks for tstate dangling pointer (#109056) (#109134)
gh-104690: thread_run() checks for tstate dangling pointer (#109056)
thread_run() of _threadmodule.c now calls
_PyThreadState_CheckConsistency() to check if tstate is a dangling
pointer when Python is built in debug mode.
Rename ceval_gil.c is_tstate_valid() to
_PyThreadState_CheckConsistency() to reuse it in _threadmodule.c.
(cherry picked from commit f63d37877ad166041489a968233b57540f8456e8)
Diffstat (limited to 'Python/ceval_gil.h')
-rw-r--r-- | Python/ceval_gil.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h index 476ed7f..d20af26 100644 --- a/Python/ceval_gil.h +++ b/Python/ceval_gil.h @@ -171,7 +171,7 @@ drop_gil(struct _ceval_runtime_state *ceval, struct _ceval_state *ceval2, /* Not switched yet => wait */ if (((PyThreadState*)_Py_atomic_load_relaxed(&gil->last_holder)) == tstate) { - assert(is_tstate_valid(tstate)); + assert(_PyThreadState_CheckConsistency(tstate)); RESET_GIL_DROP_REQUEST(tstate->interp); /* NOTE: if COND_WAIT does not atomically start waiting when releasing the mutex, another thread can run through, take @@ -226,7 +226,7 @@ take_gil(PyThreadState *tstate) PyThread_exit_thread(); } - assert(is_tstate_valid(tstate)); + assert(_PyThreadState_CheckConsistency(tstate)); PyInterpreterState *interp = tstate->interp; struct _ceval_runtime_state *ceval = &interp->runtime->ceval; struct _ceval_state *ceval2 = &interp->ceval; @@ -268,7 +268,7 @@ take_gil(PyThreadState *tstate) } PyThread_exit_thread(); } - assert(is_tstate_valid(tstate)); + assert(_PyThreadState_CheckConsistency(tstate)); SET_GIL_DROP_REQUEST(interp); drop_requested = 1; @@ -307,7 +307,7 @@ _ready: drop_gil(ceval, ceval2, tstate); PyThread_exit_thread(); } - assert(is_tstate_valid(tstate)); + assert(_PyThreadState_CheckConsistency(tstate)); if (_Py_atomic_load_relaxed(&ceval2->gil_drop_request)) { RESET_GIL_DROP_REQUEST(interp); |