Bug report
Bug description:
I found 22 free-threading race conditions during a partial Xint Code scan of cpython. These only apply to the free-threaded build, and were all found and tested on commit 0534774 built with ./configure --disable-gil --enable-asan on an M3 Mac.
I'm attaching a zip file with detailed writeups of each, as well as reproduction cases for 15 of the 22 issues. I don't have scripts reproducing the findings numbered 21, 36, 82, 94, 106, 115, or 124. Race conditions can be difficult to trigger, and even the scripts I provided are trying to win tight races and may not always work.
I know this is a lot. @colesbury suggested I create a combined issue to make the triage discussion easier.
Let me know if you have any questions or concerns. The issues were found and written up by an automated system, but I have put additional work into the validation and reporting. I do want to be respectful of everyone's time while helping to make Python better.
Writeups
Individual writeups and reproduction scripts: cpython-ft.zip
Many of the scripts are expected to crash, however some of them only produce exceptions or corrupted output. You should be able to run any of the scripts with PYTHON_GIL=1 set in your environment if you want to see a baseline without the race condition.
Finding List
CPython versions tested on:
3.14
Operating systems tested on:
macOS
Bug report
Bug description:
I found 22 free-threading race conditions during a partial Xint Code scan of cpython. These only apply to the free-threaded build, and were all found and tested on commit 0534774 built with
./configure --disable-gil --enable-asanon an M3 Mac.I'm attaching a zip file with detailed writeups of each, as well as reproduction cases for 15 of the 22 issues. I don't have scripts reproducing the findings numbered 21, 36, 82, 94, 106, 115, or 124. Race conditions can be difficult to trigger, and even the scripts I provided are trying to win tight races and may not always work.
I know this is a lot. @colesbury suggested I create a combined issue to make the triage discussion easier.
Let me know if you have any questions or concerns. The issues were found and written up by an automated system, but I have put additional work into the validation and reporting. I do want to be respectful of everyone's time while helping to make Python better.
Writeups
Individual writeups and reproduction scripts: cpython-ft.zip
Many of the scripts are expected to crash, however some of them only produce exceptions or corrupted output. You should be able to run any of the scripts with
PYTHON_GIL=1set in your environment if you want to see a baseline without the race condition.Finding List
__init__races with PRNG state access inModules/_randommodule.cModules/_hashopenssl.cObjects/typeobject.cModules/_ssl.cObjects/typeobject.cObjects/call.cModules/_elementtree.cObjects/listobject.cModules/_io/bufferedio.cModules/_elementtree.cModules/_pickle.cModules/_pickle.cPython/pystate.cPython/gc_free_threading.cModules/_ctypes/_ctypes.cObjects/dictobject.cObjects/dictobject.cPython/bytecodes.cModules/_struct.cObjects/bytesobject.c__index__causes released-buffer dereference inObjects/memoryobject.cObjects/memoryobject.cCPython versions tested on:
3.14
Operating systems tested on:
macOS