Specializing interpreter may crash if the code object of a class's __init__
method is reassigned
#122712
Labels
3.13
bugs and security fixes
interpreter-core
(Objects, Python, Grammar, and Parser dirs)
type-crash
A hard crash of the interpreter, possibly with a core dump
Uh oh!
There was an error while loading. Please reload this page.
Crash report
What happened?
The interpreter will specialize
CALL
instructions intoCALL_ALLOC_AND_ENTER_INIT
when it sees that the target of aCALL
is a heap type with a simple__init__
method (i.e. no*args
,**kwargs
, or kwonly args) and the correct number of arguments are provided to the call. TheCALL_ALLOC_AND_ENTER_INIT
verifies this condition using a weaker check based only on the argument count. It's possible to reassign the code object for a class's__init__
method using a code object that passes the argcount check inCALL_ALLOC_AND_ENTER_INIT
, but uses one of the other properties that the specializer guards against (*args
in the repro below).The following repro causes the interpreter to crash (we should construct the
*args
tuple but do not):Backtrace:
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
Linked PRs
CALL_ALLOC_AND_ENTER_INIT
handles reassignment of__code__
#122713The text was updated successfully, but these errors were encountered: