https://github.com/python/cpython/commit/6e0b327690c7dd2e4e9091f81f8ad43ad5eb1631
commit: 6e0b327690c7dd2e4e9091f81f8ad43ad5eb1631
branch: main
author: mpage <[email protected]>
committer: colesbury <[email protected]>
date: 2024-04-15T12:17:33-04:00
summary:
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.
files:
M Python/pystate.c
diff --git a/Python/pystate.c b/Python/pystate.c
index acec905484c21f..50454020b8fcab 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -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);
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]