diff options
author | Sam Gross <colesbury@gmail.com> | 2024-07-08 18:52:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 18:52:07 (GMT) |
commit | 1d3cf79a501a93a7a488fc75d4db3060c5ee7d1a (patch) | |
tree | 2e2f59a0d466ee4abccae054281be060c578e094 /Include/internal/pycore_lock.h | |
parent | 31873bea471020ca5deaf735d9acb0f1abeb1d3c (diff) | |
download | cpython-1d3cf79a501a93a7a488fc75d4db3060c5ee7d1a.zip cpython-1d3cf79a501a93a7a488fc75d4db3060c5ee7d1a.tar.gz cpython-1d3cf79a501a93a7a488fc75d4db3060c5ee7d1a.tar.bz2 |
gh-121368: Fix seq lock memory ordering in _PyType_Lookup (#121388)
The `_PySeqLock_EndRead` function needs an acquire fence to ensure that
the load of the sequence happens after any loads within the read side
critical section. The missing fence can trigger bugs on macOS arm64.
Additionally, we need a release fence in `_PySeqLock_LockWrite` to
ensure that the sequence update is visible before any modifications to
the cache entry.
Diffstat (limited to 'Include/internal/pycore_lock.h')
-rw-r--r-- | Include/internal/pycore_lock.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Include/internal/pycore_lock.h b/Include/internal/pycore_lock.h index 3824434..e6da083 100644 --- a/Include/internal/pycore_lock.h +++ b/Include/internal/pycore_lock.h @@ -228,12 +228,12 @@ PyAPI_FUNC(void) _PySeqLock_AbandonWrite(_PySeqLock *seqlock); PyAPI_FUNC(uint32_t) _PySeqLock_BeginRead(_PySeqLock *seqlock); // End the read operation and confirm that the sequence number has not changed. -// Returns 1 if the read was successful or 0 if the read should be re-tried. -PyAPI_FUNC(uint32_t) _PySeqLock_EndRead(_PySeqLock *seqlock, uint32_t previous); +// Returns 1 if the read was successful or 0 if the read should be retried. +PyAPI_FUNC(int) _PySeqLock_EndRead(_PySeqLock *seqlock, uint32_t previous); // Check if the lock was held during a fork and clear the lock. Returns 1 -// if the lock was held and any associated datat should be cleared. -PyAPI_FUNC(uint32_t) _PySeqLock_AfterFork(_PySeqLock *seqlock); +// if the lock was held and any associated data should be cleared. +PyAPI_FUNC(int) _PySeqLock_AfterFork(_PySeqLock *seqlock); #ifdef __cplusplus } |