summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapi
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 /Modules/_testcapi
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 'Modules/_testcapi')
-rw-r--r--Modules/_testcapi/pyatomic.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/Modules/_testcapi/pyatomic.c b/Modules/_testcapi/pyatomic.c
index 4f72844..850de6f 100644
--- a/Modules/_testcapi/pyatomic.c
+++ b/Modules/_testcapi/pyatomic.c
@@ -125,6 +125,7 @@ test_atomic_fences(PyObject *self, PyObject *obj) {
// Just make sure that the fences compile. We are not
// testing any synchronizing ordering.
_Py_atomic_fence_seq_cst();
+ _Py_atomic_fence_acquire();
_Py_atomic_fence_release();
Py_RETURN_NONE;
}