Tachyon sample dump/replay crashes
未關閉
還沒有人認領這個 Issue。
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先重現 python -m profiling.sampling replay prof.bin --heatmap,然後閱讀 profiling/sampling/cli.py 中 _handle_replay 附近的程式碼,以及 profiling/sampling/heatmap_collector.py 中 export 和 _generate_file_html 附近的程式碼。追蹤 dump 如何產生值為 \x00 的 stat.filename;完成的標準是 replay 受影響的 profile 時,在產生 heatmap 的過程中不再崩潰。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- performance
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100