-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Closed
Copy link
Labels
3.13bugs and security fixesbugs and 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
Bug report
PyTorch Dynamo constructs code objects with non-standard constants. This is unusual, but seems to work with the default (non-free threaded build) of CPython.
However, it crashes in the free threaded build due to a few assertions when we try to de-dupe (intern) and immortalize constants:
In compare_constants
:
Lines 2671 to 2672 in 3dd3675
_Py_FatalErrorFormat("unexpected type in compare_constants: %s", | |
Py_TYPE(op1)->tp_name); |
In `hash_const:
Lines 2692 to 2694 in 3dd3675
// This should never happen: all the constants we support have | |
// infallible hash functions. | |
Py_FatalError("code: hash failed"); |
We should more gracefully handle unexpected code object constants in the free threading build. I think the interning code should behave like _PyCode_ConstantKey()
where unhandled objects types are treated as unequal if they are not the same instance (i.e., identity comparison for unexpected types).
Linked PRs
- gh-130851: Don't crash when deduping unusual code constants. #130853
- [3.13] gh-130851: Don't crash when deduping unusual code constants (GH-130853) #130880
- gh-130851: Skip test_unusual_constants under refleak checker #130899
- gh-130851: Only intern constants of types generated by the compiler #130901
- [3.13] gh-130851: Only intern constants of types generated by the compiler (GH-130901) #130953
nascheme
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and 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