Skip to content

Commit 6e0b327

Browse files
authored
gh-117657: Quiet TSAN warning about a data race between start_the_world() and tstate_try_attach() (#117828)
TSAN erroneously reports a data race between the `_Py_atomic_compare_exchange_int` on `tstate->state` in `tstate_try_attach()` and the non-atomic load of `tstate->state` in `start_the_world`. The `_Py_atomic_compare_exchange_int` fails, but TSAN erroneously treats it as a store.
1 parent 4783206 commit 6e0b327

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Python/pystate.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,8 @@ start_the_world(struct _stoptheworld_state *stw)
22482248
PyThreadState *t;
22492249
_Py_FOR_EACH_THREAD(stw, i, t) {
22502250
if (t != stw->requester) {
2251-
assert(t->state == _Py_THREAD_SUSPENDED);
2251+
assert(_Py_atomic_load_int_relaxed(&t->state) ==
2252+
_Py_THREAD_SUSPENDED);
22522253
_Py_atomic_store_int(&t->state, _Py_THREAD_DETACHED);
22532254
_PyParkingLot_UnparkAll(&t->state);
22542255
}

0 commit comments

Comments
 (0)