Skip to content

test(agent): write fake executables from a child process - #1463

Merged
AnthonyRonning merged 1 commit into
masterfrom
codex-execrace-maple
Nov 6, 2026
Merged

AnthonyRonning merged 1 commit into
masterfrom
codex-execrace-maple

Conversation

@AnthonyRonning

@AnthonyRonning AnthonyRonning commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Master's agent-test failed on Linux in this run:

agent::external_agents::tests::claude_native_retries_only_resume_confirmed_sessions
Failed to start Claude Code: Text file busy (os error 26)

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::write holds a write descriptor for a moment. If another test forks during that window, the child inherits the descriptor until it execs, even with O_CLOEXEC. While it's open, Linux refuses to execute the file and returns ETXTBSY. 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/sh now writes these scripts, using only its builtin printf. 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. chmod stays in the test process because it doesn't open the file.

The three helpers that run what they write now share write_executable:

  • the external_agents shim, which is the one that failed
  • the integrations fake CLI
  • the login_path scripts

The fake executables in self_launch and update.rs are unchanged, because no test runs them. All of these scripts are now mode 0o700; the integrations fake CLI used 0o755.

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 ETXTBSY in 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 include reads_native_release_tar_format_and_preserves_bundle_modes, which fails on this macOS bsdtar in an unrelated crate.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

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]>
@AnthonyRonning
AnthonyRonning merged commit c2136a0 into master Nov 6, 2026
23 checks passed
@AnthonyRonning
AnthonyRonning deleted the codex-execrace-maple branch November 6, 2026 07:10
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