]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-116738: Fix thread-safety issue in re module for free threading (gh-141923)
authorAlper <alperyoney@fb.com>
Wed, 26 Nov 2025 20:40:45 +0000 (12:40 -0800)
committerGitHub <noreply@github.com>
Wed, 26 Nov 2025 20:40:45 +0000 (15:40 -0500)
commitbc9e63dd9d2931771415cca1b0ed774471d523c0
tree02c56376b3a4c9030261527fa554d45ec39c3e55
parent9ac14288d7147dbbae08a8ffd8581e0f5e6fd706
gh-116738: Fix thread-safety issue in re module for free threading (gh-141923)

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.
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