]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.13] gh-121368: Fix seq lock memory ordering in _PyType_Lookup (GH-121388) (#121505)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 8 Jul 2024 19:15:58 +0000 (21:15 +0200)
committerGitHub <noreply@github.com>
Mon, 8 Jul 2024 19:15:58 +0000 (19:15 +0000)
commitc128718f309b144ebab5ed6e4ea91fe7badab25c
tree8c2d12bd4fa7fb2b9fa30ac96e8d104df1130d32
parenteef5c6443b88e63c3c204a146ceb879b077b5365
[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>
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