]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.15] gh-151644: Fix data race in sys.setdlopenflags/getdlopenflags under free-threa...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 16 Jul 2026 10:23:07 +0000 (12:23 +0200)
committerGitHub <noreply@github.com>
Thu, 16 Jul 2026 10:23:07 +0000 (15:53 +0530)
commit9fcebd38b5f8f733ed74b9724477381617f19711
treec0a44d898e7ab7aeb94bd0492bfc69f36a07863d
parent6d6f526866426160307dbc06edf7e2666fea85fa
[3.15] gh-151644: Fix data race in sys.setdlopenflags/getdlopenflags under free-threading (gh-151768) (#153790)

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.
(cherry picked from commit cde31ec135905472f1137dddcc8227af2430d89c)

Co-authored-by: Jiucheng(Oliver) <git.jiucheng@gmail.com>
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