Repository navigation
Type slots are not thread-safe in free-threaded builds #127266
Copy link
Copy link
Closed
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes
on Nov 25, 2024 For future reference, you can reproduce this race by running the following test with TSAN enabled:
./python -m test test_opcache -m test_load_attr_method_lazy_dict- marked data race in update_one_slot in typeobject.c #131105 as a duplicate of this issue
on Mar 12, 2025 - addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
on Mar 13, 2025 2 remaining items
- added 10 commits that reference this issue
on Apr 22, 2025
Metadata
Metadata
Assignees
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Bug report
Bug description:
Modification of type slots is protected by the global type lock, however, type slots are read non-atomically without holding the type lock. For example, in
PyObject_SetItem:cpython/Objects/abstract.c
Lines 231 to 235 in 5bb059f
It's not clear how we want to address this. From @colesbury in #127169 (comment):
CPython versions tested on:
3.13, 3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs