]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-116738: Fix thread-safety issue in re module for free threading (gh-141923...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 26 Nov 2025 21:08:39 +0000 (22:08 +0100)
committerGitHub <noreply@github.com>
Wed, 26 Nov 2025 21:08:39 +0000 (21:08 +0000)
commitf47e928574187ae97c778e326739b3aa0c7dc765
tree3c60621e8e3125d71200a4a4d438777012079cce
parent96bc021d7c93587a98b13a8bd191e5c9e31a6baf
[3.14] gh-116738: Fix thread-safety issue in re module for free threading (gh-141923) (gh-141990)

Added atomic operations to `scanner_begin()` and `scanner_end()` to prevent
race conditions on the `executing` flag in free-threaded builds. Also added
tests for concurrent usage of the `re` module.

Without the atomic operations, `test_scanner_concurrent_access()` triggers
`assert(self->executing)` failures, or a thread sanitizer run emits errors.
(cherry picked from commit bc9e63dd9d2931771415cca1b0ed774471d523c0)

Co-authored-by: Alper <alperyoney@fb.com>
Include/internal/pycore_pyatomic_ft_wrappers.h
Lib/test/test_free_threading/test_re.py [new file with mode: 0644]
Misc/NEWS.d/next/Core_and_Builtins/2025-11-25-13-13-34.gh-issue-116738.MnZRdV.rst [new file with mode: 0644]
Modules/_sre/sre.c