`arraymodule`, `_decimal`: possible lazy import caches reference leaks in free-threaded builds
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug description:
As pointed out by @htjworld in https://github.com/python/cpython/pull/148088#issuecomment-4196296604:
I was wondering about the lazy init pattern in a free-threaded build. If two threads enter
build_struct_timeconcurrently withst->time_struct_time == NULL, both would callPyImport_ImportModuleAttrStringand one overwrite would leave a reference with an incremented refcount that never gets decref'd.
I noticed
arraymodule.cand_decimal.chave the same pattern, so maybe this is just accepted. But _asynciomodule.c initializes eagerly in module_init() which avoids this structurally. Was lazy chosen deliberately here over eager init in init_state()?
While I've addressed this in #148088, I think that this is a valid concern, and import caches should use CAS, just like:
If there's interest, I can do it.
(It seems similar to #149000, so perhaps a more thorough check warranted.)
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、arraymodule.c と _decimal.c の遅延初期化を、_asynciomodule.c の先行初期化および Modules/_sre/sre.c の CAS パターンと比較します。free-threaded パスについて、同時初期化と参照リークを確認します。この作業は、影響を受ける import キャッシュがその並行性パターンの下で安全であり、関連する動作が検証によってカバーされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100