Skip to content

Commit eeafc73

Browse files
asvetlovclaude
andauthored
gh-160986: Fix flaky test_popping_python_frame_is_not_native (#161073)
* gh-160986: Fix flaky test_popping_python_frame_is_not_native The unwinder can attach before the target process enters its main loop, so on slow builds (e.g. UBSan) all 10,000 samples could be taken before leaf() runs. Wait until leaf() shows up in a sample before counting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Reuse _get_stack_trace_with_retry() to wait for leaf() Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent e4dba41 commit eeafc73

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎Lib/test/test_external_inspection.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,14 @@ def leaf(depth):
20412041
except RuntimeError:
20422042
continue
20432043
break
2044+
# The unwinder can attach before the main loop starts.
2045+
_get_stack_trace_with_retry(
2046+
unwinder,
2047+
condition=lambda trace: trace[0].threads and any(
2048+
frame.funcname == "leaf"
2049+
for frame in trace[0].threads[0].frame_info
2050+
),
2051+
)
20442052
samples = 0
20452053
for _ in range(10_000):
20462054
try:

0 commit comments

Comments
 (0)