You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After some discussion on PR #145362, I noticed that in Modules/_functoolsmodule.c, all use cases of PyDict_Next do not use a critical section, which is necessary in for the free-threaded build. The docs say that for PyDict_Next:
The function is not thread-safe in the free-threaded build without external synchronization. You can use Py_BEGIN_CRITICAL_SECTION to lock the dictionary while iterating over it
I have not checked if other files are missing a critical section, but it is definitely possible. I will draft a PR shortly for this issue in the coming days, but if anyone else finds other occurrences of PyDict_Next that are not thread-safe, please let me know.
Bug report
Bug description:
After some discussion on PR #145362, I noticed that in
Modules/_functoolsmodule.c, all use cases ofPyDict_Nextdo not use a critical section, which is necessary in for the free-threaded build. The docs say that forPyDict_Next:I have not checked if other files are missing a critical section, but it is definitely possible. I will draft a PR shortly for this issue in the coming days, but if anyone else finds other occurrences of
PyDict_Nextthat are not thread-safe, please let me know.CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
PyDict_Next#145487PyDict_Next(GH-145487) #145879