Skip to content

gh-160986: Fix flaky test_popping_python_frame_is_not_native - #161073

Merged
asvetlov merged 2 commits into
python:mainfrom
asvetlov:fix-flaky-popping-frame-test
Nov 2, 2026
Merged

asvetlov merged 2 commits into
python:mainfrom
asvetlov:fix-flaky-popping-frame-test

Conversation

@asvetlov

@asvetlov asvetlov commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

The remote unwinder can attach to the child process while it is still in interpreter startup, before it enters the while True: leaf(300) loop. On slow builds the fixed window of 10,000 samples can finish before leaf() ever runs, so the test fails with AssertionError: 0 not greater than 1000 (seen on buildbots and on the UBSan GHA job, e.g. https://github.com/python/cpython/actions/runs/41240245374/job/124652687585).

The test now waits (up to SHORT_TIMEOUT) until a sample contains leaf before starting the counted sampling loop. The sampling logic is factored into a small local helper so the wait and the counted loop share it. The assertion that a popping leaf frame is never reported as <native> is unchanged.

Supersedes the closed gh-160990. Test-only change, so no NEWS entry.

🤖 Generated with Claude Code

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>
@asvetlov

asvetlov commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

@vstinner @pablogsal I've stuck with this CI error recently when I was working on another issue.
The fix is small and obvious; it increases CI stability, which is not very strong right now.

@NekoAsakura NekoAsakura left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Nit: _get_stack_trace_with_retry(unwinder, condition=...) already does the waiting, so you may reuse it to keep the change minimal and get the last error in the timeout message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@asvetlov

asvetlov commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

@NekoAsakura thanks, the suggestion is applied

@lkollar

lkollar commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

LGTM.

@asvetlov
asvetlov merged commit eeafc73 into python:main Nov 2, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants