_PyInterpreterState_DeleteExceptMain() May Cause Problems During Fork

オープン
#101,437 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python

調査の方向性

Python/pystate.c の 930-932 行付近から始め、PyOS_AfterFork_Child() から呼び出される PyInterpreterState_DeleteExceptMain() を追跡します。test__xxsubinterpreters と test_multiprocessing* テストを使って、疑われる失敗を再現または調査します。複数のインタープリターを使用した fork で、報告されているクラッシュや断続的な失敗が発生しなくなり、動作が確認された場合に回帰テストのカバレッジが追加されていれば完了です。

索引モデルが issue の本文から書いたものです。

説明

3.12 interpreter-core topic-subinterpreters type-bug

_PyInterpreterState_DeleteExceptMain() first sets the "current" thread state to NULL (while still holding the GIL) but then calls PyInterpreterState_Clear() on any other interpreter, even though it depends on there being a "current" thread set. I would expect this to cause crashes when a process with multiple interpreters if forked, since PyOS_AfterFork_Child() calls _PyInterpreterState_DeleteExceptMain(). This might explain some intermittent CI failures (e.g. with test__xxsubinterpreters or test_multiprocessing_*)

See https://github.com/python/cpython/blob/main/Python/pystate.c#L930-L932.

主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。