summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authormpage <mpage@meta.com>2024-04-23 17:20:14 (GMT)
committerGitHub <noreply@github.com>2024-04-23 17:20:14 (GMT)
commit2e7771a03d8975ee8a9918ce754c665508c3f682 (patch)
treebb462c49ac11285654f00d6efbf9ee1efc7b6ec2 /Python
parent0d221e9a1952949465df4e737e8d3189bdd9632a (diff)
downloadcpython-2e7771a03d8975ee8a9918ce754c665508c3f682.zip
cpython-2e7771a03d8975ee8a9918ce754c665508c3f682.tar.gz
cpython-2e7771a03d8975ee8a9918ce754c665508c3f682.tar.bz2
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`
Diffstat (limited to 'Python')
-rw-r--r--Python/parking_lot.c3
-rw-r--r--Python/pystate.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/Python/parking_lot.c b/Python/parking_lot.c
index d5877fe..b368b50 100644
--- a/Python/parking_lot.c
+++ b/Python/parking_lot.c
@@ -194,7 +194,8 @@ _PySemaphore_Wait(_PySemaphore *sema, PyTime_t timeout, int detach)
PyThreadState *tstate = NULL;
if (detach) {
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
PyEval_ReleaseThread(tstate);
}
diff --git a/Python/pystate.c b/Python/pystate.c
index 06806bd..bca28ce 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -2096,7 +2096,7 @@ _PyThreadState_Suspend(PyThreadState *tstate)
{
_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;
HEAD_LOCK(runtime);