`_remote_debugging`: `BinaryWriter.write_sample()` trivial segfault
未關閉
還沒有人認領這個 Issue。
extension-modules
topic-profiling
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 35.9k
- PR 合併指標
- PR 指標待擷取
描述
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:
It only checks if it's a list, and then it trusts completely:
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 Modules/_remote_debugging/binary_io_writer.c 中的 BinaryWriter.write_sample() 以及所參照的 unchecked-accessor 位置開始。使用提供的 BinaryWriter(...).write_sample([42], 2000) 呼叫重現當機,然後確認無效的公開輸入不再導致 segfault,且該行為已由適當的回歸測試涵蓋。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, python
- 領域
- devtools
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 25/100