Skip to content

Conversation

mpage
Copy link
Contributor

@mpage mpage commented Apr 17, 2024

TSAN reports a couple of data races between the compare/exchange in _PySeqLock_LockWrite:

else if (_Py_atomic_compare_exchange_uint32(&seqlock->sequence, &prev, prev + 1)) {

and the non-atomic loads in _PySeqLock_AbandonWrite (example race):

cpython/Python/lock.c

Lines 493 to 495 in a23fa33

void _PySeqLock_AbandonWrite(_PySeqLock *seqlock)
{
uint32_t new_seq = seqlock->sequence - 1;

and _PySeqLock_UnlockWrite (example race):

cpython/Python/lock.c

Lines 500 to 502 in a23fa33

void _PySeqLock_UnlockWrite(_PySeqLock *seqlock)
{
uint32_t new_seq = seqlock->sequence + 1;

This is another instance of TSAN incorrectly modeling failed compare/exchange as a write instead of a load.

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.
@mpage mpage requested review from DinoV and colesbury April 17, 2024 04:40
@mpage mpage marked this pull request as ready for review April 17, 2024 05:40
Copy link
Contributor

@DinoV DinoV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ghost
Copy link

ghost commented Apr 17, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants