Repository navigation
Fix ETXTBSY flake in process command_for spawn test - #1377
Merged
Merged
Conversation
command_for_spawns_the_resolved_path_directly_on_unix writes a shell shim, chmods it and spawns it at once. A sibling test thread that forks between our open() and its own exec() inherits the shim's write fd, and exec'ing the shim in that window fails with "Text file busy" (os error 26). Seen in the coverage job of CI run 37999238426. Spawn through a test-local output_of_fresh_shim helper that retries ErrorKind::ExecutableFileBusy only, with a 10s deadline and 20ms sleeps. This is the same pattern as sanity_exec in update/download.rs and the CLI's exec_freshly_written fixture. Any other spawn error still panics, and the assertions are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Mikola Lysenko (mikolalysenko)
enabled auto-merge
October 10, 2026 00:40
Tanmay Singla (Tanmay182003)
approved these changes
Oct 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Failing run
The coverage job in CI run 37999238426 failed on 2026-10-09 in
utils::process::tests::command_for_spawns_the_resolved_path_directly_on_unix:Root cause
This is the known ETXTBSY fork/exec race. The test writes a shell shim, chmods it and spawns it at once.
fs::writecloses our handle, but other test threads in the same process fork children. A child forked between ouropen()and its ownexec()inherits the shim's write fd, and Linux refuses to exec a file while any process holds it open for writing. Writing to a temp file and renaming it would not help, because the inherited fd still refers to the same inode.Fix
The test now spawns through a test-local
output_of_fresh_shimhelper. It retriesErrorKind::ExecutableFileBusyonly, with a 10 s deadline and 20 ms sleeps, the same pattern assanity_execinupdate/download.rsand the CLI'sexec_freshly_writtenfixture. Any other spawn error still panics, and the test's assertions are unchanged.I checked the other core tests that write executables. The only other test that writes and runs a shim is
a_hung_probe_answers_none_within_its_budget. It expectsNone, so an ETXTBSY there can't fail it, and I left it alone.Verification
cargo test -p socket-patch-core --lib utils::process: 25/25 serial runs and 10/10 runs with--test-threads=64passed.cargo test -p socket-patch-core --libpassed once (6164 tests).cargo clippy --locked --workspace --all-features -- -D warningsis clean.🤖 Generated with Claude Code
Note
Low Risk
Test-only change in
utils::processtests; no production spawn or resolver logic is modified.Overview
Fixes intermittent CI failure in
command_for_spawns_the_resolved_path_directly_on_unixwhen parallel test threads hit Linux ETXTBSY (“Text file busy”) after writing and immediately exec’ing a temp shim.Adds a Unix-only test helper
output_of_fresh_shimthat retries spawn onErrorKind::ExecutableFileBusyonly (10s cap, 20ms backoff), matchingsanity_exec/ CLIexec_freshly_written. The test now spawns the resolved shim through that helper; assertions and productioncommand_forbehavior are unchanged.Reviewed by Cursor Bugbot for commit 256d857. Configure here.