Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Abort from calling OrderedDict.setdefault with an invalid value #132461

Copy link
Copy link
Open
@devdanzin

Description

@devdanzin
Issue body actions

Crash report

What happened?

It's possible to abort the interpreter by passing a class that has invalid, changing hash values to OrderedDict.setdefault:

from abc import ABCMeta
from random import randint

large_num = 2**64
class WeirdBase(ABCMeta):
  def __hash__(self):
    return randint(0, large_num)


class weird_bytes(bytes, metaclass=WeirdBase):
    pass

from collections import OrderedDict

obj = OrderedDict()

for x in range(100):
    obj.setdefault(weird_bytes, None)

Abort message:

python: Objects/odictobject.c:1036: OrderedDict_setdefault_impl: Assertion `_odict_find_node(self, key) == NULL' failed.

Program received signal SIGABRT, Aborted.

Found using fusil by @vstinner.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

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

Python 3.14.0a6+ (heads/main:be2d2181e62, Mar 31 2025, 07:30:17) [GCC 11.4.0]

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.