Skip to content

fix(luggage): serialize shim-writing validate tests to close fork/exec race - #481

Merged
joshjhall merged 1 commit into
mainfrom
fix/luggage-validate-shim-race
May 17, 2026
Merged

fix(luggage): serialize shim-writing validate tests to close fork/exec race#481
joshjhall merged 1 commit into
mainfrom
fix/luggage-validate-shim-race

Conversation

@joshjhall

Copy link
Copy Markdown
Owner

Summary

  • Mark the three shim-writing tests in crates/luggage/src/installer/validate.rs with #[serial_test::serial] to close the same fork+ETXTBSY race that fix(luggage): serialize shim-writing idempotency tests to close fork/exec race #459 fixed for installer::idempotency.
  • The three tests (matching_output_passes, mismatched_output_returns_validation_failed, propagates_env_to_subprocess) use the identical write_shim + Command::output() pattern but were never serialized.

Root cause

CI run 25982111224 — the merge-to-main of #479 — failed on Ubuntu only with:

test installer::validate::tests::mismatched_output_returns_validation_failed ... FAILED
thread '...' panicked at crates/luggage/src/installer/validate.rs:127:17:
assertion failed: message.contains(\"1.95.0\")

The assertion fires inside the `ValidationFailed { message, .. }` arm. The only `message` formats that don't contain the requested version are the launch-failure branches (`binary not found`, `failed to launch`, `exited N: ...`). Under parallel `cargo test`, one thread's in-flight write-FD on the shim raises `i_writecount` while another thread forks for `execve`, and the child returns `ETXTBSY` (rust-lang/rust#100904). Ubuntu's faster fork/exec exposes it; macOS / Windows runners did not reproduce.

This is the same diagnosis and fix recipe that #459 applied to `idempotency.rs` — the `serial_test` dev-dep is already wired in.

Test plan

  • `cargo test -p luggage --lib installer::validate` — 4/4 pass
  • `cargo test -p luggage --lib` — 151/151 pass
  • `cargo clippy -p luggage --tests -- -D warnings` — clean
  • Stress: ran `cargo test -p luggage --lib installer::validate` 25× consecutively — all green

🤖 Generated with Claude Code

…c race

The three `installer::validate` tests that write a shell shim and then
`Command::output()` it intermittently fail under parallel `cargo test`
due to the same fork+ETXTBSY race (rust-lang/rust#100904) that #459
fixed for `installer::idempotency`: one thread's in-flight write FD
raises the inode's i_writecount while another thread forks for execve,
and the child gets ETXTBSY. Validate's tests use the identical
`write_shim` pattern but were never serialized.

Observed in CI run 25982111224 on the merge-to-main of #479, where
`mismatched_output_returns_validation_failed` failed with
`assertion failed: message.contains("1.95.0")` — the shim's exec
returned an ETXTBSY error message that, naturally, doesn't contain
the target version string. Ubuntu's faster fork/exec exposes the race
more reliably than macOS / Windows.

Mark all three shim-writing tests (`matching_output_passes`,
`mismatched_output_returns_validation_failed`,
`propagates_env_to_subprocess`) with `#[serial_test::serial]`. The
crate's `serial_test` dev-dependency was already added in #459.
Verified by running `cargo test -p luggage --lib installer::validate`
25x consecutively — all green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joshjhall
joshjhall merged commit de54a2d into main May 17, 2026
21 of 23 checks passed
@joshjhall
joshjhall deleted the fix/luggage-validate-shim-race branch May 17, 2026 16:00
joshjhall added a commit that referenced this pull request May 17, 2026
Bug-fix patch release for the 2026-05-17 auto-patch incident:

- fix(luggage) #481: serialize shim-writing validate tests to close
  fork+ETXTBSY race that broke `cargo test` on Ubuntu after the v4.19.1
  merge.
- fix(tests) #485: make `tests/changed_features.sh` exit 0 on
  no-feature-match input (was tripping `set -u` on empty assoc array
  and silently failing PR-tier `Detect changed features` on every
  workflow/docs/base-images PR since #467).
- fix(ci) #484: skip `upload-sarif` on ephemeral `auto-patch/**` refs
  to prevent `ref not found` errors after the auto-merge branch
  cleanup.
- fix(ci) #483: move the auto-patch compatibility-matrix update from
  the pre-merge `auto-merge` job to the `post-merge` job so the SHA
  that ships matches the SHA the original CI validated.
- fix(base) #482: add `apt-get upgrade -y` to the debian-12-amd64 base
  image so fresh builds pick up Debian security advisories (libc-bin,
  libcap2, libsystemd0 — all HIGH-severity, all fixed upstream).

No behavior changes to the build matrix, feature scripts, or runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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