Skip to content

Commit 23d90c0

Browse files
dyurk-lilaclaude
andcommitted
test(profiler): don't start real kineto in step-fault test (fixes teardown segfault)
test_step_failure_disables_without_raising started a real torch.profiler session, then nulled self.prof via the fault path without stopping it. The orphaned libkineto session crashed at interpreter shutdown (exit 139), surfacing as a CPU-CI teardown segfault after all tests passed. Swap the faulting stub in before start() so no real profiler is ever opened; the swallow-and-disable path is still exercised. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 421c669 commit 23d90c0

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

tests/backends/skyrl_train/utils/test_profiler.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,29 @@ def test_activities_threaded_to_torch(tmp_path):
147147

148148
def test_step_failure_disables_without_raising(tmp_path):
149149
prof = Profiler(_ProfCfg(save_path=str(tmp_path)))
150-
prof.start()
151150

152151
class _Boom:
152+
"""Stands in for a live torch profiler whose ``step`` faults. ``start``/
153+
``stop`` are no-ops: we must NOT start the real kineto profiler here, or
154+
the wrapper's fault path nulls ``self.prof`` while that session is still
155+
running, leaving it unstopped -> libkineto segfaults at interpreter exit
156+
(process-wide, surfaces as a teardown crash long after this test passes)."""
157+
158+
def start(self):
159+
pass
160+
153161
def step(self):
154162
raise RuntimeError("boom")
155163

156-
# Simulate an internal profiler fault mid-loop; the wrapper must swallow it.
164+
def stop(self):
165+
pass
166+
167+
# Swap in the faulting stub BEFORE start() so no real profiler session is ever
168+
# opened; this still exercises the wrapper's swallow-and-disable path.
157169
prof.prof = _Boom()
170+
prof.start()
171+
172+
# Simulate an internal profiler fault mid-loop; the wrapper must swallow it.
158173
prof.step()
159174
assert prof.enable is False
160175
assert prof.prof is None

0 commit comments

Comments
 (0)