Repository navigation
test(agent): write fake executables from a child process - #1463
Merged
Merged
Conversation
Master's agent-test failed on Linux with "Failed to start Claude Code: Text file busy (os error 26)" while running a fake CLI a test had just written. A fork in another test inherits every descriptor open in this process until that child execs, and the kernel refuses to run a file that is open for writing. A short-lived shell now writes these scripts, so the test process never holds a write descriptor for a fork to inherit. The three helpers that run what they write share this one, and the other fake executables stay as they are because no test runs them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Problem
Master's
agent-testfailed on Linux in this run:This is a race in the tests, not a product bug. The product code only tried to start a fake CLI the test had just written.
Root cause
fs::writeholds a write descriptor for a moment. If another test forks during that window, the child inherits the descriptor until it execs, even withO_CLOEXEC. While it's open, Linux refuses to execute the file and returnsETXTBSY. Tests run in parallel and this binary starts many processes, so the failure is rare but can happen in any test that writes a script and runs it.Fix
A short-lived
/bin/shnow writes these scripts, using only its builtinprintf. The test process never opens the file for writing, so there's no descriptor for a fork to inherit. That removes the race, where a retry would only hide it.chmodstays in the test process because it doesn't open the file.The three helpers that run what they write now share
write_executable:external_agentsshim, which is the one that failedintegrationsfake CLIlogin_pathscriptsThe fake executables in
self_launchandupdate.rsare unchanged, because no test runs them. All of these scripts are now mode0o700; theintegrationsfake CLI used0o755.Testing
cargo test -p maple-agent: 847 passed, 0 failed, 5 ignored, on macOS.just ci-lint: clean.The fix itself isn't proven by a local run. A stress program writing scripts directly hit 0
ETXTBSYin 3378 runs on macOS, so this doesn't reproduce here, and I have no Linux environment to run it on. The cause rests on the error above and documented Linux behaviour. The failure is rare, so one green CI run won't prove it either.The pre-commit hook was skipped with
MAPLE_HOOK_SKIP=1. Its workspace tests includereads_native_release_tar_format_and_preserves_bundle_modes, which fails on this macOSbsdtarin an unrelated crate.🤖 Generated with Claude Code
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.