Repository navigation
Segfault on cls.__dict__['__new__'].__annotations__ #125017
Copy link
Copy link
Closed
Labels
3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Activity
- addedinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump3.14bugs and security fixesbugs and security fixes
on Oct 6, 2024 @JelleZijlstra I took a quick glance at the implementation and PR, and I think this is a matter of forgetting to initialize
sm_dictandcm_dictin constructors. IIRC, iftp_dictoffsetis used, the dictionary won't get created until someone tries to access__dict__, so here it ends up being NULL, and thus segfaulting.Thanks @ZeroIntensity, I agree that's the right diagnosis. Found a related crash too:
Python 3.14.0a1+ (heads/main-dirty:a5a7f5e16d8, Oct 16 2024, 22:38:43) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> @classmethod ... def f(): pass ... >>> del f.__annotations__ Assertion failed: (!_PyErr_Occurred(tstate)), function _PyEval_EvalFrameDefault, file generated_cases.c.h, line 5059. Abort trap: 6
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-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?
The following is a reproducer of (another) segfault discovered when trying to test Python 3.14 in CI for Sphinx:
Whilst checking
__annotations__directly is somewhat convoluted, it was originally triggered byinspect.isasyncgenfunction(), which callsinspect._signature_is_functionlike()via_has_code_flag().A similar error occurs with
__class_getitem__and__init_subclass__, but not with user-defined methdods declared with eitherclassmethodorstaticmethod. As the reproducer demonstrates, the segfault only happens with the descriptor object from__dict__--cls.__new__.__annotations__is fine.Bisection showed this to be due to d28afd3 (#119864), cc @JelleZijlstra
A
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.14.0a0 (bisect/bad:d28afd3fa06, Oct 6 2024, 01:35:23) [GCC 13.2.0]
Linked PRs