python / python/cpython

Torn reads of GC statistics from external process via get_gc_stats

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

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

3.15 3.16 extension-modules interpreter-core type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug report

Bug description:

If an external tool sampling GC statistics does not pause the target process (and we designed get_gc_stats not to pause), it can read torn data under certain circumstances.

There are two distinct problems:

  1. Weakly ordered platforms: The stores of ts_start and ts_stop may be reordered by the CPU/optimizer. We need to add memory barriers to mitigate this.

  2. Large memcpy window: We are copying a sufficiently large memory region via memcpy. If two or more GC cycles occur during this copy, we can end up with inconsistent data spanning multiple GC states.

@maurycy has an idea to use a sequence counter for consistency checks — I think he should definitely give it a try.

cc @pablogsal

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-155828

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

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

はじめの一歩

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

調査の方向性

まず get_gc_stats と ts_start および ts_stop を格納している箇所を追跡し、次に外部プロセスが GC データをどのように観測するかについて memcpy パスを確認してください。最初にリンクされた PR gh-155828 と関連するテストをすべて読んでください。弱いメモリ順序付けのプラットフォームで、外部サンプリングが GC サイクルをまたいで分断されたスナップショットを返さなくなれば完了です。

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

評価

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

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

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