python / python/cpython

Tachyon sample dump/replay crashes

Đang mở
#144,336 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

stdlib topic-profiling type-bug
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện python -m profiling.sampling replay prof.bin --heatmap, sau đó đọc profiling/sampling/cli.py quanh _handle_replayprofiling/sampling/heatmap_collector.py quanh export_generate_file_html. Theo dõi cách một dump có thể tạo ra stat.filename có giá trị \x00; công việc được xem là hoàn tất khi replay profile bị ảnh hưởng không còn bị crash trong lúc tạo heatmap.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
performance
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.