Skip to content

Abort from GenericAlias.__sizeof__: ob->ob_type != &PyLong_Type #127603

Closed
@devdanzin

Description

@devdanzin

Crash report

What happened?

It's possible to abort the interpreter in 3.12 by calling __sizeof__ of a GenericAlias instance:

from types import GenericAlias

g = GenericAlias(BaseException, Exception)
g.__sizeof__(1)

Abort message:

python: ./Include/object.h:231: Py_SIZE: Assertion `ob->ob_type != &PyLong_Type' failed.
Aborted

Found using fusil by @vstinner.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.12.8+ (heads/3.12:8e3c2d2, Dec 4 2024, 10:58:33) [GCC 11.4.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions