diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-07-08 19:15:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-08 19:15:58 (GMT) |
commit | c128718f309b144ebab5ed6e4ea91fe7badab25c (patch) | |
tree | 8c2d12bd4fa7fb2b9fa30ac96e8d104df1130d32 /Include/cpython/pyatomic_std.h | |
parent | eef5c6443b88e63c3c204a146ceb879b077b5365 (diff) | |
download | cpython-c128718f309b144ebab5ed6e4ea91fe7badab25c.zip cpython-c128718f309b144ebab5ed6e4ea91fe7badab25c.tar.gz cpython-c128718f309b144ebab5ed6e4ea91fe7badab25c.tar.bz2 |
[3.13] gh-121368: Fix seq lock memory ordering in _PyType_Lookup (GH-121388) (#121505)
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.
(cherry picked from commit 1d3cf79a501a93a7a488fc75d4db3060c5ee7d1a)
Co-authored-by: Sam Gross <colesbury@gmail.com>
Diffstat (limited to 'Include/cpython/pyatomic_std.h')
-rw-r--r-- | Include/cpython/pyatomic_std.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Include/cpython/pyatomic_std.h b/Include/cpython/pyatomic_std.h index 0cdce4e..7c71e94 100644 --- a/Include/cpython/pyatomic_std.h +++ b/Include/cpython/pyatomic_std.h @@ -962,6 +962,13 @@ _Py_atomic_fence_seq_cst(void) } static inline void +_Py_atomic_fence_acquire(void) +{ + _Py_USING_STD; + atomic_thread_fence(memory_order_acquire); +} + + static inline void _Py_atomic_fence_release(void) { _Py_USING_STD; |