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
{{ message }}
Repository navigation
Free-threading: dict() crashes when a key/value pair list is mutated concurrently #159244
In the free-threaded build, dict() and dict.update() can crash when an item of the iterable is a list that another thread mutates. merge_from_seq2_lock_held() in Objects/dictobject.c checks that the pair has two items, then reads both with PySequence_Fast_GET_ITEM(), which returns borrowed references, without holding the list's lock. A concurrent clear() in between leaves it reading from a freed or NULL item array.
On main (aab474a) built with --disable-gil --with-pydebug --with-address-sanitizer, this crashes in every run I tried:
==420189==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008
SUMMARY: AddressSanitizer: SEGV Objects/dictobject.c:4151 in merge_from_seq2_lock_held
str.join() (gh-119247) and bytes.join() (gh-158803) had the same pattern and now use Py_BEGIN_CRITICAL_SECTION_SEQUENCE_FAST. The same code is in 3.13, 3.14 and 3.15.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
changed the title [-]Title: Free-threading: dict() crashes when a key/value pair list is mutated concurrently[/-][+]Free-threading: dict() crashes when a key/value pair list is mutated concurrently[/+]on Oct 12, 2026
Activity
[-]Title: Free-threading: dict() crashes when a key/value pair list is mutated concurrently[/-][+]Free-threading: dict() crashes when a key/value pair list is mutated concurrently[/+]