Heap types implemented in C must have Py_TPFLAGS_HAVE_GC and implement tp_traverse
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 35.9k
- PR 合并指标
- PR 指标待抓取
描述
If a heap type does not have Py_TPFLAGS_HAVE_GC or doesn't not implement tp_traverse, the garbage collector may fail to collect the type and most of its instances at Python exit. The problem is worse when sub-interpreters are involved: if a sub-interpreter exits and does not clear all of its memory, the other interpreters will continue running with these leaks.
See issue gh-87138 for the rationale.
I wrote an article on the lock type which had this bug and caused a memory leak: https://vstinner.github.io/subinterpreter-leaks.html
Linked PRs
- gh-116947
- gh-138290
- gh-138327
- gh-138328
- gh-138331
- gh-138333
- gh-138427
- gh-138428
- gh-138334
- gh-138340
- gh-138341
- gh-138582
- gh-138807
- gh-139073
- gh-139474
- gh-141268
- gh-141448
- gh-152310
- gh-156034
The following PRs were directly closed because the types are immutable and empty:
- gh-138329
- gh-138330
- gh-138332
The following PRs were wrongly merged so we reverted them:
- gh-138266
- gh-138320
- gh-138322
- gh-138288
- gh-138321
- gh-138323
- gh-138289
- gh-138324
- gh-138326
PRs for reverting the above commits:
- gh-138338
- gh-138337
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue gh-87138 和关于 lock type 的链接文章开始,然后盘点链接 PR 涵盖的 C heap types。完成的标准是:适用的 heap types 具有 Py_TPFLAGS_HAVE_GC 和 tp_traverse,并且已解决所描述的解释器退出时和子解释器中的泄漏问题。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100