Repository navigation
process: unregister Windows wait before closing child handle - #8564
Merged
Merged
Conversation
On Windows, `tokio::process::imp::Child` previously declared `child: StdChild` before `waiting: Option<Waiting>`. Because Rust drops struct fields in declaration order, dropping a `Child` with an active wait registration closed the underlying process handle in `StdChild::drop` before `Waiting::drop` called `UnregisterWaitEx`, violating the Win32 `RegisterWaitForSingleObject` contract. Reorder the fields of `Child` so that `waiting` is dropped before `child`, ensuring `UnregisterWaitEx` completes before `StdChild` closes the process handle. Fixes: tokio-rs#8563
GlenDC
requested changes
Oct 2, 2026
GlenDC
left a comment
Member
There was a problem hiding this comment.
Fix looks correct to me. Will this be forward-ported? master still has the old field order.
Member
Author
|
Yes, forward port is part of our release process. |
GlenDC
approved these changes
Oct 2, 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.
On Windows,
tokio::process::imp::Childpreviously declaredchild: StdChildbeforewaiting: Option<Waiting>. Because Rust drops struct fields in declaration order, dropping aChildwith an active wait registration closed the underlying process handle inStdChild::dropbeforeWaiting::dropcalledUnregisterWaitEx, violating the Win32RegisterWaitForSingleObjectcontract.Reorder the fields of
Childso thatwaitingis dropped beforechild, ensuringUnregisterWaitExcompletes beforeStdChildcloses the process handle.Fixes: #8563