Heap types implemented in C must have Py_TPFLAGS_HAVE_GC and implement tp_traverse
まだ誰も着手していません。
- 主要言語
- 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 にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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