3.13.2: cast in Py_XDECREF causes runtime failures with immortal objects
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
In Python 3.13.2 I use
Py_XDECREF(PyObject *op)
It is called at the end of a function-call to load an image (cv2.imread) which fails, resulting in a None value (not NULL!). For Python 3.9 Py_XDECREF works just fine, without crash. For Python 3.13.2 the program, compiled with VS2022 (64 Bit), raises a "Run-Time Check Failure #1 - A cast to a smaller data type has caused a loss of data." and my application crashes ("/RTC1 = Basic Runtime Checks enabled").
I followed up the calls:
Py_DECREF
_Py_IsImmortal
#elif SIZEOF_VOID_P > 4
_Py_CAST(PY_INT32_T, op->ob_refcnt) <-- crash
The value is
op->ob_refcnt == 0x0000000100000000
To fix this problem, I propose, that the type cast to 32 bit should be changed to
_Py_CAST(PY_INT32_T, op->ob_refcnt & 0xFFFFFFFF)
CPython versions tested on:
3.13
Operating systems tested on:
Windows
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Py_XDECREF/Py_DECREF と _Py_IsImmortal の呼び出しパスから始め、報告されている immortal reference count を使って Windows VS2022 /RTC1 の失敗を再現します。cast の動作を提案されたマスキングと比較し、その後、関連する CPython テストを使って失敗が解消されたことを確認します。この issue では特定のソースファイルやテストは指定されていません。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, python
- 領域
- backend, operating-systems
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100