python / python/cpython

Tachyon sample dump/replay crashes

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

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

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

説明

Bug description:

I'm running python -m profiling.sampling replay prof.bin --heatmap after having captured some profile and it crashes.

When I dropped a breakpoint in I saw the dump somehow has ended up with one instance where stat.filename == '\x00'

Error: Failed to export heatmap: embedded null byte
Traceback (most recent call last):
  File "<frozen runpy>", line 196, in _run_module_as_main
  File "<frozen runpy>", line 87, in _run_code
  File "/.../lib/python3.15/profiling/sampling/__main__.py", line 65, in <module>
    main()
    ~~~~^^
  File "/.../lib/python3.15/profiling/sampling/cli.py", line 788, in main
    _main()
    ~~~~~^^
  File "/.../lib/python3.15/profiling/sampling/cli.py", line 922, in _main
    handler(args)
    ~~~~~~~^^^^^^
  File "/.../lib/python3.15/profiling/sampling/cli.py", line 1206, in _handle_replay
    collector.export(filename)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/.../lib/python3.15/profiling/sampling/heatmap_collector.py", line 725, in export
    self._generate_file_reports(output_dir, file_stats)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.15/profiling/sampling/heatmap_collector.py", line 766, in _generate_file_reports
    self._generate_file_html(
    ~~~~~~~~~~~~~~~~~~~~~~~~^
        file_path,
        ^^^^^^^^^^
    ...<3 lines>...
        stat
        ^^^^
    )
    ^
  File "/.../lib/python3.15/profiling/sampling/heatmap_collector.py", line 905, in _generate_file_html
    source_lines = Path(filename).read_text(encoding='utf-8', errors='replace').splitlines()
                   ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.15/pathlib/__init__.py", line 985, in read_text
    with self.open(mode='r', encoding=encoding, errors=errors, newline=newline) as f:
         ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/.../lib/python3.15/pathlib/__init__.py", line 969, in open
    return io.open(self, mode, buffering, encoding, errors, newline)
           ~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: embedded null byte

Don't yet have a minimal repro, but maybe the issue is apparent to you

CPython versions tested on:

3.15

Operating systems tested on:

macOS

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

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

はじめの一歩

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

調査の方向性

まず python -m profiling.sampling replay prof.bin --heatmap を再現し、次に profiling/sampling/cli.py_handle_replay 付近と、profiling/sampling/heatmap_collector.pyexport および _generate_file_html 付近を読みます。dump によって値が \x00stat.filename が生成される仕組みを追跡します。影響を受けたプロファイルを replay しても heatmap の生成中にクラッシュしなくなれば完了です。

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

評価

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

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

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