python / python/cpython

profiling.sampling heatmap reads non-regular and oversized files

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

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

stdlib topic-profiling type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

Bug description

The heatmap exporter in profiling.sampling reads source files named in a profile unconditionally via Path(filename).read_text(). It does not check whether the path is a regular file or whether the file size is reasonable.

When replaying a binary profile, a filename pointing to a device file (e.g. /dev/zero) causes unbounded memory growth. An oversized file has the same effect.

The fix adds an is_file() guard and a 10 MB size cap before reading, consistent with the binary reader hardening in gh-152718.

CPython versions tested on

main

Operating systems tested on

macOS

Linked PRs
  • gh-153839

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

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

はじめの一歩

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

調査の方向性

source パスが Path(filename).read_text() で読み取られている profiling.sampling のヒートマップエクスポーターから始め、gh-152718 のバイナリリーダーの強化と比較してください。完了の条件は、通常ファイルではないパスと 10 MB を超えるファイルが読み取られないことです。gh-153839 は提案された作業としてすでにリンクされています。

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

評価

技術スタック
python
領域
performance
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
25/100

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

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