mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-117657: Quiet erroneous TSAN reports of data races in _PySeqLock
(#117955)
Quiet erroneous TSAN reports of data races in `_PySeqLock` TSAN reports a couple of data races between the compare/exchange in `_PySeqLock_LockWrite` and the non-atomic loads in `_PySeqLock_{Abandon,Unlock}Write`. This is another instance of TSAN incorrectly modeling failed compare/exchange as a write instead of a load.
This commit is contained in:
parent
b6c62c79e7
commit
0d29302155
2 changed files with 3 additions and 5 deletions
|
@ -472,7 +472,7 @@ _PyRWMutex_Unlock(_PyRWMutex *rwmutex)
|
|||
|
||||
void _PySeqLock_LockWrite(_PySeqLock *seqlock)
|
||||
{
|
||||
// lock the entry by setting by moving to an odd sequence number
|
||||
// lock by moving to an odd sequence number
|
||||
uint32_t prev = _Py_atomic_load_uint32_relaxed(&seqlock->sequence);
|
||||
while (1) {
|
||||
if (SEQLOCK_IS_UPDATING(prev)) {
|
||||
|
@ -492,14 +492,14 @@ void _PySeqLock_LockWrite(_PySeqLock *seqlock)
|
|||
|
||||
void _PySeqLock_AbandonWrite(_PySeqLock *seqlock)
|
||||
{
|
||||
uint32_t new_seq = seqlock->sequence - 1;
|
||||
uint32_t new_seq = _Py_atomic_load_uint32_relaxed(&seqlock->sequence) - 1;
|
||||
assert(!SEQLOCK_IS_UPDATING(new_seq));
|
||||
_Py_atomic_store_uint32(&seqlock->sequence, new_seq);
|
||||
}
|
||||
|
||||
void _PySeqLock_UnlockWrite(_PySeqLock *seqlock)
|
||||
{
|
||||
uint32_t new_seq = seqlock->sequence + 1;
|
||||
uint32_t new_seq = _Py_atomic_load_uint32_relaxed(&seqlock->sequence) + 1;
|
||||
assert(!SEQLOCK_IS_UPDATING(new_seq));
|
||||
_Py_atomic_store_uint32(&seqlock->sequence, new_seq);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue