Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35.2k
Assigning __conditional_annotations__ crashes the interpreter #154902
Copy link
Copy link
Closed
Labels
3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixes3.16new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-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?
In CPython 3.14 and later, assigning to the global
__conditional_annotations__before a variable annotation produces a segfault.Here is a minimal reproducible example:
Analyzing the bytecode, the compiler first initializes
__conditional_annotations__to an empty set. Whenever an annotation is declared, aSET_ADDis emitted under the assumption that the underlying type is still a set. But we can re-assign__conditional_annotations__to another object in between, leading to a type confusion:CPython versions tested on:
3.14, 3.15
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
Linked PRs