mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
gh-140263: Fix data race in test_lock_two_threads (gh-140264)
Clang-20 detects a data race between the unlock and the non-atomic read of the lock state. Use a relaxed load for the assertion to avoid the race.
This commit is contained in:
parent
e4f6445f30
commit
f11ec6e643
1 changed files with 2 additions and 1 deletions
|
|
@ -91,7 +91,8 @@ test_lock_two_threads(PyObject *self, PyObject *obj)
|
||||||
} while (v != 3 && iters < 200);
|
} while (v != 3 && iters < 200);
|
||||||
|
|
||||||
// both the "locked" and the "has parked" bits should be set
|
// both the "locked" and the "has parked" bits should be set
|
||||||
assert(test_data.m._bits == 3);
|
v = _Py_atomic_load_uint8_relaxed(&test_data.m._bits);
|
||||||
|
assert(v == 3);
|
||||||
|
|
||||||
PyMutex_Unlock(&test_data.m);
|
PyMutex_Unlock(&test_data.m);
|
||||||
PyEvent_Wait(&test_data.done);
|
PyEvent_Wait(&test_data.done);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue