All projects

Upstream commits

CPython

python/cpython

Free-threaded crash fixes in dict(), bytes.join() and codecs.encode(), MemoryError crash fixes, and _Py_ThreadId() on Windows ARM64 with MinGW.

View on GitHub

7 commits

  1. gh-159244: Fix crash in dict() on a concurrently mutated key/value pair (#159245)
    In the free-threaded build, dict() and dict.update() checked that a list key/value pair had two items and then read them with borrowed references without holding its lock, so another thread could empty the list in between and the items were read from a freed or NULL array.
  2. gh-159294: Fix crash when creating an `ExceptionGroup` fails with `MemoryError` (#159295)
  3. gh-159399: Fix crash in codecs.encode() on a concurrently unregistered codec (#159400)
    * gh-159399: Fix crash in codecs.encode() on a concurrently unregistered codec In the free-threaded build, codec_getitem() released the CodecInfo tuple returned by _PyCodec_Lookup() before taking a reference to the encoder or decoder it returns. If another thread cleared the lookup cache in between with codecs.unregister(), the tuple could hold the last reference to the item, which was then freed before it was increfed. Take the reference before releasing the tuple, as codec_getitem_checked() already does. * Remove the free-threading stress test
  4. gh-159285: Fix crash when copying an empty dict fails with MemoryError (#159286)
    copy_lock_held_untracked() asserted that the new empty dict was not tracked by the GC without checking whether its allocation had failed, so a debug build dereferenced NULL instead of raising MemoryError. This affected dict.copy(), PyDict_Copy() and _PyDict_CopyAsDict(), which type() uses for the class namespace.
  5. gh-158803: Fix crash in bytes.join() on a concurrently mutated list (#158910)
    In the free-threaded build, bytes.join() and bytearray.join() read items from the list with borrowed references and without holding its lock, so another thread could replace and free an item before it was increfed. Run the join under Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST, as PyUnicode_Join() already does.
  6. gh-74112: Fix race in test_interrupt_blocking_call (GH-158914)
    On a loaded machine the KeyboardInterrupt could be raised before the main thread reached time.sleep(), escape the test and stop the whole regrtest run.
  7. gh-157212: Fix _Py_ThreadId() on Windows ARM64 with MinGW (gh-157253)

Updated daily, last on 2026-11-16. By Christian Aurich Zanettini Martins · All projects