Skip to content

Commit 0d52383

Browse files
authored
gh-117657: Quiet more TSAN warnings due to incorrect modeling of compare/exchange (#117830)
1 parent 6e0b327 commit 0d52383

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/pystate.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2003,7 +2003,7 @@ tstate_try_attach(PyThreadState *tstate)
20032003
static void
20042004
tstate_set_detached(PyThreadState *tstate, int detached_state)
20052005
{
2006-
assert(tstate->state == _Py_THREAD_ATTACHED);
2006+
assert(_Py_atomic_load_int_relaxed(&tstate->state) == _Py_THREAD_ATTACHED);
20072007
#ifdef Py_GIL_DISABLED
20082008
_Py_atomic_store_int(&tstate->state, detached_state);
20092009
#else
@@ -2068,7 +2068,7 @@ static void
20682068
detach_thread(PyThreadState *tstate, int detached_state)
20692069
{
20702070
// XXX assert(tstate_is_alive(tstate) && tstate_is_bound(tstate));
2071-
assert(tstate->state == _Py_THREAD_ATTACHED);
2071+
assert(_Py_atomic_load_int_relaxed(&tstate->state) == _Py_THREAD_ATTACHED);
20722072
assert(tstate == current_fast_get());
20732073
if (tstate->critical_section != 0) {
20742074
_PyCriticalSection_SuspendAll(tstate);

0 commit comments

Comments
 (0)