Repository navigation
str.maketrans on a mutating dict is not thread-safe #145142
Copy link
Copy link
Closed
Labels
easyinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Activity
- addedtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dumpinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on Feb 23, 2026 Yes,
PyDict_Nextisn't thread-safe if there are concurrent modifications of the dict. We should wrap the loop with a critical section onxhere.Do you want to make the change?
Do you want to make the change?
I am adding the easy label for newcomers. If not picked up, I will make the change.
Reacted by Sam GrossI am working on this issue.
- added 5 commits that reference this issue
on Feb 23, 2026
Metadata
Metadata
Assignees
Labels
easyinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Crash report
What happened?
A reproducer (in the format of
Lib/tests/test_free_threading/xxx.py):At first glance it seems that the iteration using
PyDict_Nextis not safe (but maybe there are more unsafe parts):cpython/Objects/unicodeobject.c
Line 13158 in 24cc998
(found when reviewing #145129)
CPython versions tested on:
CPython main branch
Operating systems tested on:
Windows
Output from running 'python -VV' on the command line:
No response
Linked PRs