test_sampling_with_collapsed_export fails when the profiler records an unreadable frame
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start with test_sampling_with_collapsed_export in Lib/test/test_profiling/test_sampling_profiler/test_integration.py and compare its colon assertion with the documented unreadable frame and GC frame output. The issue suggests accepting special <...> frames in this assertion; check related handling in test_binary_format.py for context. Done when the test accepts those special frames while still checking ordinary collapsed frames, and passes.
由索引模型根據 Issue 內容生成。
描述
Bug report
Bug description:
test_sampling_with_collapsed_export failed in the ASan job of my PR gh-160296 (the change there is in a multiprocessing test and is unrelated):
FAIL: test_sampling_with_collapsed_export (test.test_profiling.test_sampling_profiler.test_integration.TestSampleProfilerIntegration.test_sampling_with_collapsed_export)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/cpython/cpython/Lib/test/test_profiling/test_sampling_profiler/test_integration.py", line 512, in test_sampling_with_collapsed_export
self.assertIn(":", part)
~~~~~~~~~~~~~^^^^^^^^^^^
AssertionError: ':' not found in '<unreadable frame>'
https://github.com/python/cpython/actions/runs/39832455069/job/120012213367
Since gh-154194, _remote_debugging returns a degraded frame (file "~", no location, function "<unreadable frame>") when it cannot read a code object, instead of failing the sample. CollapsedStackCollector turns the None location into line 0, and export() writes frames with file "~" and line 0 as just the function name, so the collapsed line contains <unreadable frame> with no colon. The test expects every part to look like file:func:line, so it fails whenever a sample hits an unreadable frame. I have only seen it on the ASan build so far.
gh-154195 updated test_binary_format.py for the new frame, but not this test.
Reproducer, without a target process:
import os
import tempfile
from profiling.sampling.stack_collector import CollapsedStackCollector
collector = CollapsedStackCollector(1000)
# The first (innermost) frame is what _remote_debugging returns
# when it cannot read a code object (gh-154194).
frames = [
("~", None, "<unreadable frame>", None),
("/tmp/script.py", (10, 10, 0, 1), "main", None),
]
collector.process_frames(frames, thread_id=1)
fd, path = tempfile.mkstemp(suffix=".txt")
os.close(fd)
collector.export(path)
with open(path) as f:
line = f.read().strip()
os.unlink(path)
print(line)
stack_trace = line.rsplit(" ", 1)[0]
for part in stack_trace.split(";"):
print(repr(part), ":" in part)
Output:
Collapsed stack output written to /tmp/tmp....txt
tid:1;script.py:main:10;<unreadable frame> 1
'tid:1' True
'script.py:main:10' True
'<unreadable frame>' False
<GC> frames (on by default in sample()) take the same "~" branch in export(), so they would fail this assertion too. The test could accept these special <...> frames instead of requiring a colon. I can open a PR if that approach is fine.
The same test and the gh-154194 change are also in 3.15.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, macOS
- 主要語言
- Python
- 星號
- 77.7k
- 分支
- 38.3k
- 平均合併
- 12 小時 12 分鐘
- 30 天內合併 PR
- 650
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/cpython 的其他 Issue
-
type-bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
extension-modules type-bug
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
interpreter-core type-feature
難度 1/5 1 小時以內 新手友好度 78/100
python/cpython#160109 · 1 則留言 ·
維護者通常 1 天內回覆
-
extension-modules type-bug
難度 2/5 1-3 小時 新手友好度 72/100
python/cpython#160001 · 3 則留言 ·
維護者通常 1 天內回覆
-
stdlib topic-XML type-bug
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 1/5 1-3 小時 新手友好度 85/100
WLAN-Pi/wlanpi-profiler#341 ·
維護者通常 1 天內回覆
-
Memory leak: the shared `validation_aborted_error` keeps every traceback it is raised through可能已有人在做 @Fire162 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
graphql-python/graphql-core#287 ·
-
難度 2/5 1-3 小時 新手友好度 67/100
roman-corgi/ctc-dip#160 ·
維護者通常 1 天內回覆
-
render_findings.py reads and writes in the host's default encoding, so findings.html breaks on a cp1252 Windows host可能已有人在做 @Aaqibhafeezkhan 今天認領。 未關閉bug good first issue mentored python size: XS up-for-grabs
難度 2/5 1-3 小時 新手友好度 75/100
dheerajjha/mcp-migrate#366 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆