]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-121368: Fix seq lock memory ordering in _PyType_Lookup (#121388)
authorSam Gross <colesbury@gmail.com>
Mon, 8 Jul 2024 18:52:07 +0000 (14:52 -0400)
committerGitHub <noreply@github.com>
Mon, 8 Jul 2024 18:52:07 +0000 (14:52 -0400)
commit1d3cf79a501a93a7a488fc75d4db3060c5ee7d1a
tree2e2f59a0d466ee4abccae054281be060c578e094
parent31873bea471020ca5deaf735d9acb0f1abeb1d3c
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.
Include/cpython/pyatomic.h
Include/cpython/pyatomic_gcc.h
Include/cpython/pyatomic_msc.h
Include/cpython/pyatomic_std.h
Include/internal/pycore_lock.h
Misc/NEWS.d/next/Core and Builtins/2024-07-04-23-38-30.gh-issue-121368.m3EF9E.rst [new file with mode: 0644]
Modules/_testcapi/pyatomic.c
Objects/typeobject.c
Python/lock.c