mirror of https://github.com/python/cpython
gh-117657: Quiet TSAN warnings about remaining non-atomic accesses of `tstate->state` (#118165)
Quiet TSAN warnings about remaining non-atomic accesses of `tstate->state`
This commit is contained in:
parent
0d221e9a19
commit
2e7771a03d
|
@ -194,7 +194,8 @@ _PySemaphore_Wait(_PySemaphore *sema, PyTime_t timeout, int detach)
|
||||||
PyThreadState *tstate = NULL;
|
PyThreadState *tstate = NULL;
|
||||||
if (detach) {
|
if (detach) {
|
||||||
tstate = _PyThreadState_GET();
|
tstate = _PyThreadState_GET();
|
||||||
if (tstate && tstate->state == _Py_THREAD_ATTACHED) {
|
if (tstate && _Py_atomic_load_int_relaxed(&tstate->state) ==
|
||||||
|
_Py_THREAD_ATTACHED) {
|
||||||
// Only detach if we are attached
|
// Only detach if we are attached
|
||||||
PyEval_ReleaseThread(tstate);
|
PyEval_ReleaseThread(tstate);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2096,7 +2096,7 @@ _PyThreadState_Suspend(PyThreadState *tstate)
|
||||||
{
|
{
|
||||||
_PyRuntimeState *runtime = &_PyRuntime;
|
_PyRuntimeState *runtime = &_PyRuntime;
|
||||||
|
|
||||||
assert(tstate->state == _Py_THREAD_ATTACHED);
|
assert(_Py_atomic_load_int_relaxed(&tstate->state) == _Py_THREAD_ATTACHED);
|
||||||
|
|
||||||
struct _stoptheworld_state *stw = NULL;
|
struct _stoptheworld_state *stw = NULL;
|
||||||
HEAD_LOCK(runtime);
|
HEAD_LOCK(runtime);
|
||||||
|
|
Loading…
Reference in New Issue