Skip to content

Commit

Permalink
pythongh-117657: Quiet TSAN warning about a data race between `start_…
Browse files Browse the repository at this point in the history
…the_world()` and `tstate_try_attach()` (python#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.
  • Loading branch information
mpage authored and diegorusso committed Apr 17, 2024
1 parent c267ff8 commit 2b5a7e4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,8 @@ start_the_world(struct _stoptheworld_state *stw)
PyThreadState *t;
_Py_FOR_EACH_THREAD(stw, i, t) {
if (t != stw->requester) {
assert(t->state == _Py_THREAD_SUSPENDED);
assert(_Py_atomic_load_int_relaxed(&t->state) ==
_Py_THREAD_SUSPENDED);
_Py_atomic_store_int(&t->state, _Py_THREAD_DETACHED);
_PyParkingLot_UnparkAll(&t->state);
}
Expand Down

0 comments on commit 2b5a7e4

Please sign in to comment.