python / python/cpython

`_remote_debugging`: `BinaryWriter.write_sample()` trivial segfault

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

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

extension-modules 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 report

Bug description:
[139] 2026-09-09T18:57:09.249268000+0200 maurycy@gimel /Users/maurycy/work/cpython (main 52ffffe) % ./python.exe 
Python 3.16.0a0 (heads/main:83dbe6ae9f4, Sep  6 2026, 18:18:16) [Clang 21.0.0 (clang-2100.1.1.101)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import _remote_debugging
>>> _remote_debugging.BinaryWriter("/tmp/o.bin", 1000, 1000000).write_sample([42], 2000)
zsh: segmentation fault  ./python.exe

There's many more variants, easy to come up with.

This is the place:

https://github.com/python/cpython/blob/52ffffe0a23bf0f4a57ee00377c5aeb965b3a29a/Modules/_remote_debugging/binary_io_writer.c#L1013

It only checks if it's a list, and then it trusts completely:

https://github.com/python/cpython/blob/52ffffe0a23bf0f4a57ee00377c5aeb965b3a29a/Modules/_remote_debugging/binary_io_writer.c#L841-L848

https://github.com/python/cpython/blob/52ffffe0a23bf0f4a57ee00377c5aeb965b3a29a/Modules/_remote_debugging/binary_io_writer.c#L928-L930

https://github.com/python/cpython/blob/52ffffe0a23bf0f4a57ee00377c5aeb965b3a29a/Modules/_remote_debugging/binary_io_writer.c#L1020-L1023

The comment says Use unchecked accessors since we control the data structures but I still think that segmentation fault on a public method is not great.

I will submit a PR soon.

ref #148178

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-157228

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 trong Modules/_remote_debugging/binary_io_writer.c tại BinaryWriter.write_sample() và các vị trí unchecked-accessor được tham chiếu. Tái hiện sự cố bằng lệnh gọi BinaryWriter(...).write_sample([42], 2000) được cung cấp, sau đó xác minh rằng các đầu vào công khai không hợp lệ không còn gây ra segfault và hành vi này được bao phủ bởi các bài kiểm thử hồi quy phù hợp.

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

Đánh giá

Công nghệ
c, python
Lĩnh vực
devtools
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
Đặc tả rõ ràng
Mức phù hợp với người mới
25/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.