gc.get_referrers() can be used to see objects before they are fully built
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
Crash report
That the problem is occurring in the Py_INCREF macro, it looks like that the error occurs because the code is trying to increment the reference count of an object that doesnt exist.
Steps to reproduce the behavior:
1.create a sample file that contains:
import gc
def g():
marker = object()
yield marker
[tup] = [x for x in gc.get_referrers(marker) if type(x) is tuple]
print(tup)
print(tup[1])
tuple(g())
- just run without opt:
./target/python/Python-3.11.1/builded/bin/python3.11 ./target/python/founded/sig11_sync_Python3111_52.py
Error messages
stderr:
(<object object at 0x7f9e66d10160>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>, <NULL>)
Segmentation fault (core dumped)
gdb:
After run with synthetical sample, binary file aborted with Segfault:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 Py_INCREF (op=0x0) at ./Include/object.h:502
warning: Source file is more recent than executable.
502 #ifdef Py_REF_DEBUG
Expected behavior
No assertion failed.
Additional context
For solution this problem added additional checking to ensure that the op argument is not a null pointer before trying to increment its reference count.
if (op == NULL) {
return;
}
(also added in a patch)
Environment
- Tested on: Python 3.11.1
- Operating system and architecture: Centos-based system (RED OS release MUROM (7.3.2)) ; 5.15.78-2.el7.3.x86_64
Linked PRs
- gh-101856
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
gc.get_referrers() と tuple(g()) を使用する Python の例で問題を再現し、その後、報告で指定されている Py_INCREF の位置にある Include/object.h を調べます。観測された NULL エントリと segmentation fault を、リンクされている PR gh-101856 と比較します。reproducer が無効なタプルエントリを公開せず、クラッシュもしなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100