3.13.2: cast in Py_XDECREF causes runtime failures with immortal objects
還沒有人認領這個 Issue。
- 主要語言
- 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 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Py_XDECREF/Py_DECREF 和 _Py_IsImmortal 的呼叫路徑開始,使用回報的 immortal reference count 重現 Windows VS2022 /RTC1 失敗。將 cast 行為與提議的 masking 進行比較,然後使用相關的 CPython 測試驗證該失敗已獲得解決;該 issue 未指定特定的原始碼檔案或測試。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, python
- 領域
- backend, operating-systems
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100