test_sampling_with_collapsed_export fails when the profiler records an unreadable frame
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 78/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 77.7k
- Forks
- 38.3k
- Ø Merge
- 12 Std. 27 Min.
- Gemergte PRs (30 T.)
- 645
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python/cpython
-
extension-modules type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
Maintainer antworten meist innerhalb von 1 Tag
-
tests topic-multiprocessing type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 71/100
Maintainer antworten meist innerhalb von 1 Tag
-
interpreter-core type-feature
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 78/100
python/cpython#160109 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
extension-modules type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
python/cpython#160001 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
stdlib topic-XML type-bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
Python Volcengine provider returns failures instead of raising themEvtl. vergeben @Ricardo-M-L hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
agent-infra/sandbox#248 ·
-
Textractor leaves empty temporary files when remote retrieval failsEvtl. vergeben @HuaTNA hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
test(bm_generation): pin the learning parameters and CPU sync shortcutEvtl. vergeben @iloveeyjafjalla hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
qboson/kaiwu-pytorch-plugin#1341 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
elder-plinius/V3R1T4S#625 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
foxglove/mcap#1907 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag