]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-151644: Fix data race in sys.setdlopenflags/getdlopenflags under free-threading...
authorJiucheng(Oliver) <git.jiucheng@gmail.com>
Fri, 3 Jul 2026 20:19:09 +0000 (16:19 -0400)
committerGitHub <noreply@github.com>
Fri, 3 Jul 2026 20:19:09 +0000 (13:19 -0700)
commitcde31ec135905472f1137dddcc8227af2430d89c
tree8e86dcaa72158a053d802a87f6b8a18360afc33c
parent423ae0ff36c6485f722e0fe3274124dc3df09862
gh-151644: Fix data race in sys.setdlopenflags/getdlopenflags under free-threading (gh-151768)

In free-threading builds, concurrent calls to sys.getdlopenflags() and
sys.setdlopenflags() race on interp->imports.dlopenflags.  Fix by
using FT_ATOMIC_LOAD_INT_RELAXED / FT_ATOMIC_STORE_INT_RELAXED in
_PyImport_GetDLOpenFlags and _PyImport_SetDLOpenFlags, consistent with
how analogous interpreter-state integer fields (lazy_imports_mode,
pystats_enabled) are protected.

Relaxed ordering is correct here: dlopenflags is a standalone config
integer with no ordering relationship to other memory.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Lib/test/test_free_threading/test_sys.py
Misc/NEWS.d/next/Core_and_Builtins/2026-06-18-00-00-00.gh-issue-151644.5cFffN.rst [new file with mode: 0644]
Python/import.c