Repository navigation
fix(spawn): start detached Windows runtimes in jobs that forbid breakaway - #12
Open
olebhansen wants to merge 1 commit into
Open
olebhansen wants to merge 1 commit into
olebhansen wants to merge 1 commit into
Conversation
…away The SDK starts a detached runtime with CREATE_BREAKAWAY_FROM_JOB so that it outlives the launcher's job object. When the launcher is in a job without JOB_OBJECT_LIMIT_BREAKAWAY_OK, CreateProcess refuses with ERROR_ACCESS_DENIED and the SDK reported a bare permission error that looked like a file problem. This hits `cargo test`, whose kill-on-close job breaks create_detached() and modify().restart(), and agentd started from sandboxed tool shells. Retry without the breakaway flag when the first attempt is refused, and log a warning. If the retry also fails, the error names the process start and both causes. Trade-off: a runtime started this way stays in the launcher's job, so it ends when that job is terminated or closed with kill-on-close, for example when the test run or the shell exits. The alternative is not starting at all, since such a job lets no child escape. Launchers in no job, or in a job that allows breakaway, behave as before. The launch contract is unchanged; COMPATIBILITY.md records the lifecycle change. The new test reproduces the refusal in a kill-on-close job without breakaway and checks that the detached process starts inside that job. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The SDK starts detached runtimes on Windows with
CREATE_BREAKAWAY_FROM_JOB. When the launcher sits in a job object that does not allow breakaway,CreateProcessrefuses withERROR_ACCESS_DENIED. The SDK then reported a barePermissionDenied(os error 5) that looked like a file problem. This affectscargo test, whose kill-on-close job breakscreate_detached()andmodify().restart(), and agentd when it is started from sandboxed tool shells.The SDK now retries without breakaway and logs a warning. If the retry also fails, the error names the process start and both causes.
This was the third commit of #10. It moved here because Windows nested virtualization will come from upstream in the next fork sync. Upstream still spawns with breakaway and has no fallback, so this fix stays in the patch queue.
Compatibility
A runtime started inside a job that forbids breakaway stays in that job. It ends when the job is terminated, or when its last handle closes with kill-on-close, such as when the test run or the shell exits. Before this change it did not start at all. Launchers in no job, or in a job that allows breakaway, behave as before. Launch arguments, JSON, handles and runtime state are unchanged.
COMPATIBILITY.mdrecords the lifecycle change.Tests
On Windows 11 Enterprise 26200, Intel:
windows_detached_spawn_stays_in_job_without_breakawayputs the test in a kill-on-close job without breakaway. It checks that the detached process starts and runs inside that job.runtime::spawn::tests::windows_tests pass.cargo clippy -p microsandbox -- -D warningsis clean.cargo testwith this fix. Before it,nested_virt_can_be_modified_on_an_existing_sandboxfailed with os error 5.🤖 Generated with Claude Code