Skip to content

Fix supervisor race condition when spawning child processes on Windows#18171

Draft
zanieb wants to merge 1 commit intozb/fix-bounce-race-iifrom
zb/fix-spawn-race
Draft

Fix supervisor race condition when spawning child processes on Windows#18171
zanieb wants to merge 1 commit intozb/fix-bounce-race-iifrom
zb/fix-spawn-race

Conversation

@zanieb
Copy link
Member

@zanieb zanieb commented Feb 23, 2026

This is the same as #18170 but for uvx and uv run instead of trampolines.

Set CREATE_SUSPENDED for Windows spawn supervision, assign the child to
the job object, then resume the process. This removes the post-spawn
assignment race for short-lived child processes.

If job assignment fails, kill the suspended child before returning an
error to avoid leaving a stuck suspended process.
@zanieb zanieb changed the title Spawn supervised child suspended before job assignment Fix supervisor race condition when spawning child processes on Windows Feb 23, 2026
@zanieb zanieb added bug Something isn't working windows Specific to the Windows platform labels Feb 23, 2026
@zanieb zanieb force-pushed the zb/fix-bounce-race-ii branch 3 times, most recently from ad44925 to b2ac908 Compare February 25, 2026 18:58
Comment on lines +82 to +83
// We use `NtResumeProcess` later because `std::process::Child` does not
// expose the primary thread handle needed for `ResumeThread`.
Copy link
Collaborator

@samypr100 samypr100 Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use #![feature(windows_process_extensions_main_thread_handle)] and then do child.main_thread_handle().as_raw_handle() instead which allows you to use ResumeThread and avoid NtResumeProcess.

edit: nevermind, this is still nighly only 😆 my head is stuck in trampoline which is nightly

@zanieb
Copy link
Member Author

zanieb commented Mar 16, 2026

We'll need an alternative of this like #18291 I presume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working windows Specific to the Windows platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants