Skip to content

test(session): fix drip-writer PID parse race (musl unit-test flake) - #1220

Merged
zackees merged 1 commit into
mainfrom
fix/musl-drip-pid-parse
Sep 26, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/musl-drip-pid-parse

Conversation

@zackees

@zackees zackees commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Fixes the intermittent musl / unit-test failure of async_api::async_process_session_test::session_post_exit_grace_is_a_cumulative_pipe_read_budget that blocks #1217 (zackees/setup-soldr#528).

Root cause

It is a race in the test. The Rust caches are not involved.

testbin-session-pipe-holder spawns testbin-session-drip-writer, which inherits the same stdout pipe. Only after that does the holder print GRANDCHILD_PID=<pid>. The drip writer starts writing . right away, so it sometimes gets a byte into the pipe before the holder's println!. The transcript then reads .GRANDCHILD_PID=123\n..... The test did split_whitespace().find_map(|w| w.strip_prefix("GRANDCHILD_PID=")), which never matches .GRANDCHILD_PID=123. The result is the expect("fixture reports drip-writer pid") panic at line 526, even though abandoned was true.

This ordering depends on scheduling, which is why the same commit passes on one runner and fails on another (ae15e7b vs 5acb3ff, e82a4cf vs 49c1af4). The 35 ms grace is not the problem: the PID line is written well before the holder exits.

Evidence

  • Running the fixtures directly on x86_64-unknown-linux-musl 200 times: 7 runs started with .GRANDCHILD_PID=... instead of GRANDCHILD_PID=....
  • CI job 108368155532 (run 36227526416) fails with the same message at the same line.

Fix

The test now looks for the GRANDCHILD_PID= marker anywhere in the transcript and parses the digits after it. The timing contract, the grace value and the fixtures are unchanged.

RED -> GREEN (x86_64-unknown-linux-musl, single test looped)

  • Before: 3/300 failures, panic at async_process_session_test.rs:526
  • After: 0/1000 failures

Validation

  • soldr cargo fmt --all -- --check: pass
  • soldr cargo clippy --workspace --all-targets -- -D warnings: pass, also with -p running-process --features async-process --tests
  • soldr cargo build --workspace: pass
  • musl async_process_session_test module: 15/15 pass
  • cargo check --tests --features async-process for x86_64-pc-windows-msvc and aarch64-apple-darwin: pass
  • bash ./lint: pass

🤖 Generated with Claude Code

The drip writer inherits the holder's stdout and writes '.' as soon as it
is spawned, sometimes before the holder prints GRANDCHILD_PID=<pid>. The
transcript then reads '.GRANDCHILD_PID=123', which the whitespace-word
strip_prefix parse rejects. Search for the marker as a substring instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zackees
zackees merged commit 0081c7a into main Sep 26, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant