Skip to content

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

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]

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Dec 4, 2024
  2. vstinner commented on Dec 4, 2024

    @vstinner
    Member

    I created #127605 backport to fix the issue.

  3. vstinner commented on Dec 11, 2024

    @vstinner
    Member

    Fixed by commit 0964f9f. Thanks for your bug report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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