`super.__new__(super)` can create an object that causes a NULL dereference in supercheck()
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Crash report
What happened?
super.__new__(super) can create a super object whose internal type field is NULL. Using that object as a descriptor then causes a segmentation fault in supercheck().
Minimal reproducer:
s = super.__new__(super)
print(s)
s.__get__(1)
Output:
<super: <class 'NULL'>, NULL>
Segmentation fault (core dumped)
The one-line form also reproduces the crash:
super.__new__(super).__get__(1)
This is deterministic on the tested build.
A normal initialized super object does not crash:
class A:
pass
class B(A):
pass
s = super(B, B())
print(s.__get__(B()))
Output:
<super: <class 'B'>, ...>
GDB confirms the NULL dereference:
Program received signal SIGSEGV, Segmentation fault.
supercheck (type=0x0, obj=...)
at Objects/typeobject.c:12605
The crashing code is:
PyErr_Format(PyExc_TypeError,
"super(type, obj): obj (%s %.200s) is not "
"an instance or subtype of type (%.200s).",
type_or_instance, obj_str, type->tp_name);
Here type == NULL, so evaluating type->tp_name dereferences NULL.
The relevant call path is:
super.__new__(super)
-> PyType_GenericNew()
-> uninitialized super object (su->type == NULL)
-> super_descr_get()
-> supercheck(su->type, obj)
-> type->tp_name
-> SIGSEGV
PySuper_Type currently uses PyType_GenericNew as its tp_new, while initialization of the internal fields is performed separately by super_init. Therefore direct use of super.__new__(super) bypasses that initialization.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.16.0a0 (heads/audit-objects-phase1-dirty:c3aefdb9eff, Aug 7 2026, 19:38:01) [GCC 13.3.0]
Linked PRs
- gh-155379
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Objects/typeobject.c の supercheck() から始め、次に PySuper_Type の PyType_GenericNew と、レポートで説明されている別の super_init パスを追跡します。super.new(super).get(1) を使った再現コードを回帰カバレッジとして使用します。クラッシュせず、代わりに適切なエラーを報告するようになれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100