mirror of
https://github.com/python/cpython.git
synced 2025-08-10 03:49:18 +00:00
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 f63d37877a
)
This commit is contained in:
parent
9207c870be
commit
30748d36b3
4 changed files with 35 additions and 20 deletions
|
@ -1072,9 +1072,12 @@ static void
|
|||
thread_run(void *boot_raw)
|
||||
{
|
||||
struct bootstate *boot = (struct bootstate *) boot_raw;
|
||||
PyThreadState *tstate;
|
||||
PyThreadState *tstate = boot->tstate;
|
||||
|
||||
// gh-104690: If Python is being finalized and PyInterpreterState_Delete()
|
||||
// was called, tstate becomes a dangling pointer.
|
||||
assert(_PyThreadState_CheckConsistency(tstate));
|
||||
|
||||
tstate = boot->tstate;
|
||||
_PyThreadState_Bind(tstate);
|
||||
PyEval_AcquireThread(tstate);
|
||||
tstate->interp->threads.count++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue