-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Open
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs 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
Bug report
In _Py_slot_tp_getattr_hook
, the assignment tp->tp_getattro = _Py_slot_tp_getattro
is not thread-safe. It's unlikely to cause any real problems in practice, but it currently necessitates a suppression.
Lines 10581 to 10586 in 9d3b53c
getattr = _PyType_LookupRef(tp, &_Py_ID(__getattr__)); | |
if (getattr == NULL) { | |
/* No __getattr__ hook: use a simpler dispatcher */ | |
tp->tp_getattro = _Py_slot_tp_getattro; | |
return _Py_slot_tp_getattro(self, name); | |
} |
I think we should disable the assignment in the free threaded build:
- It's not necessary for correctness
- It's not really important for performance because we specialize this code path anyways
- Even without the specialization, this doesn't seem particularly important to me. The cost of the
_PyType_LookupRef
isn't huge and classes that use__getattribute__
aren't super common -- they are less common than classes that use__getattr__
.
I'll put up a PR for this soon.
cc @nascheme
Linked PRs
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs 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