Abort from calling `OrderedDict.setdefault` with an invalid value
オープン
まだ誰も着手していません。
interpreter-core
type-crash
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
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
- gh-132462
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Objects/odictobject.c の OrderedDict_setdefault_impl の assertion から始め、issue にある Python スニペットを使ってクラッシュを再現してください。すでに進行中の作業については、リンクされている PR gh-132462 を確認してください。invalid-changing hash case によってインタープリターが中断されなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100