summaryrefslogtreecommitdiffstats
path: root/Include/internal
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-07-08 18:52:07 (GMT)
committerGitHub <noreply@github.com>2024-07-08 18:52:07 (GMT)
commit1d3cf79a501a93a7a488fc75d4db3060c5ee7d1a (patch)
tree2e2f59a0d466ee4abccae054281be060c578e094 /Include/internal
parent31873bea471020ca5deaf735d9acb0f1abeb1d3c (diff)
downloadcpython-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')
-rw-r--r--Include/internal/pycore_lock.h8
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
}