mirror of https://github.com/python/cpython.git
gh-116396: Pass "detached_state" argument to tstate_set_detached (#116398)
The stop-the-world code was incorrectly setting suspended threads' states to _Py_THREAD_DETACHED instead of _Py_THREAD_SUSPENDED.
This commit is contained in:
parent
d9bcdda39c
commit
834bf57eb7
|
@ -903,7 +903,7 @@ _PyInterpreterState_Clear(PyThreadState *tstate)
|
||||||
|
|
||||||
|
|
||||||
static inline void tstate_deactivate(PyThreadState *tstate);
|
static inline void tstate_deactivate(PyThreadState *tstate);
|
||||||
static void tstate_set_detached(PyThreadState *tstate);
|
static void tstate_set_detached(PyThreadState *tstate, int detached_state);
|
||||||
static void zapthreads(PyInterpreterState *interp);
|
static void zapthreads(PyInterpreterState *interp);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1686,7 +1686,7 @@ _PyThreadState_DeleteCurrent(PyThreadState *tstate)
|
||||||
#ifdef Py_GIL_DISABLED
|
#ifdef Py_GIL_DISABLED
|
||||||
_Py_qsbr_detach(((_PyThreadStateImpl *)tstate)->qsbr);
|
_Py_qsbr_detach(((_PyThreadStateImpl *)tstate)->qsbr);
|
||||||
#endif
|
#endif
|
||||||
tstate_set_detached(tstate);
|
tstate_set_detached(tstate, _Py_THREAD_DETACHED);
|
||||||
tstate_delete_common(tstate);
|
tstate_delete_common(tstate);
|
||||||
current_fast_clear(tstate->interp->runtime);
|
current_fast_clear(tstate->interp->runtime);
|
||||||
_PyEval_ReleaseLock(tstate->interp, NULL);
|
_PyEval_ReleaseLock(tstate->interp, NULL);
|
||||||
|
@ -1859,13 +1859,13 @@ tstate_try_attach(PyThreadState *tstate)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
tstate_set_detached(PyThreadState *tstate)
|
tstate_set_detached(PyThreadState *tstate, int detached_state)
|
||||||
{
|
{
|
||||||
assert(tstate->state == _Py_THREAD_ATTACHED);
|
assert(tstate->state == _Py_THREAD_ATTACHED);
|
||||||
#ifdef Py_GIL_DISABLED
|
#ifdef Py_GIL_DISABLED
|
||||||
_Py_atomic_store_int(&tstate->state, _Py_THREAD_DETACHED);
|
_Py_atomic_store_int(&tstate->state, detached_state);
|
||||||
#else
|
#else
|
||||||
tstate->state = _Py_THREAD_DETACHED;
|
tstate->state = detached_state;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1935,7 +1935,7 @@ detach_thread(PyThreadState *tstate, int detached_state)
|
||||||
_Py_qsbr_detach(((_PyThreadStateImpl *)tstate)->qsbr);
|
_Py_qsbr_detach(((_PyThreadStateImpl *)tstate)->qsbr);
|
||||||
#endif
|
#endif
|
||||||
tstate_deactivate(tstate);
|
tstate_deactivate(tstate);
|
||||||
tstate_set_detached(tstate);
|
tstate_set_detached(tstate, detached_state);
|
||||||
current_fast_clear(&_PyRuntime);
|
current_fast_clear(&_PyRuntime);
|
||||||
_PyEval_ReleaseLock(tstate->interp, tstate);
|
_PyEval_ReleaseLock(tstate->interp, tstate);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue