Reference leak in code object with reference loop
未關閉
還沒有人認領這個 Issue。
3.13
3.14
3.15
interpreter-core
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
If the code object creates a reference loop, this causes a reference leak. For example (see :
def f():
return 1234.5
code = f.__code__
a = []
code = code.replace(co_consts=code.co_consts + (a,))
a.append(code)
(See https://github.com/python/cpython/blob/d61fcf834d197f0113a6a507fdbecc1545d9d483/Lib/test/test_marshal.py#L354-L360 added in #148698)
This is because in the GIL-enabled build the code object does not support GC and does not have tp_traverse.
Linked PRs
- gh-151155
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Lib/test/test_marshal.py 中約第 354-360 行的重現程式碼和所引用的回歸測試開始。檢查啟用 GIL 的程式碼物件如何處理垃圾回收和走訪,重點關注 issue 中描述的缺少支援。完成的標準是參照迴圈不再洩漏,且 marshal 測試繼續通過。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- backend
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100