summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-06-01 14:51:55 (GMT)
committerGitHub <noreply@github.com>2024-06-01 14:51:55 (GMT)
commit48054d2306fed2a2a53d8e5dba9c1aa7ef138ed5 (patch)
tree459c3f111aeef9718d9d1fe919c26d48e514636c /Python
parent48f3378d6c620e99f17679ee11982a57640d3bb4 (diff)
downloadcpython-48054d2306fed2a2a53d8e5dba9c1aa7ef138ed5.zip
cpython-48054d2306fed2a2a53d8e5dba9c1aa7ef138ed5.tar.gz
cpython-48054d2306fed2a2a53d8e5dba9c1aa7ef138ed5.tar.bz2
[3.13] gh-117657: Fix TSAN race in QSBR assertion (GH-119887) (#119904)
Due to a limitation in TSAN, all reads from `PyThreadState.state` must be atomic to avoid reported races. (cherry picked from commit 90ec19fd33e2452902b9788d4821f1fbf6542304) Co-authored-by: Sam Gross <colesbury@gmail.com>
Diffstat (limited to 'Python')
-rw-r--r--Python/qsbr.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/qsbr.c b/Python/qsbr.c
index 9cbce90..a732115 100644
--- a/Python/qsbr.c
+++ b/Python/qsbr.c
@@ -160,7 +160,8 @@ qsbr_poll_scan(struct _qsbr_shared *shared)
bool
_Py_qsbr_poll(struct _qsbr_thread_state *qsbr, uint64_t goal)
{
- assert(_PyThreadState_GET()->state == _Py_THREAD_ATTACHED);
+ assert(_Py_atomic_load_int_relaxed(&_PyThreadState_GET()->state) == _Py_THREAD_ATTACHED);
+
if (_Py_qbsr_goal_reached(qsbr, goal)) {
return true;
}