wslc: assert Pid > 0 in DockerExecProcessControl::SetPid#40567
Merged
Conversation
Defense-in-depth follow-up to PR microsoft#40550. The exec polling loop in WSLCContainerImpl::Exec now correctly filters Pid > 0 before calling SetPid, but a future caller that bypassed that check would silently hang the process wait (because Docker never emits exec_die for a process that never spawned). Assert at the lowest level so any such regression fires loudly in Debug builds. Suggested by @OneBlue in the PR microsoft#40550 review. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
OneBlue
approved these changes
May 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a debug-only contract check in the wslc Docker exec process-control path to ensure an exec PID is always a real, forked process ID, preventing future regressions of the previously-fixed “Pid=0 treated as running” hang scenario.
Changes:
- Add
WI_ASSERT(Pid > 0)toDockerExecProcessControl::SetPidto enforce the caller contract in Debug builds. - Add an explanatory comment documenting Docker’s transient
Pid=0behavior and the hang failure mode.
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.
Summary
Defense-in-depth follow-up to #40550. Adds
WI_ASSERT(Pid > 0)inDockerExecProcessControl::SetPidso any future caller that bypasses thestate.Pid > 0filter in the exec polling loop is caught immediately in Debug builds.Background
#40550 fixed a hang in
WSLCContainerImpl::Execwhere Docker's transient{Running=true, Pid=0}response (seen on fast runc failures, e.g.-u root:badgid) was treated as a valid running process. The polling loop now filtersstate.Pid > 0before callingSetPid, so production behavior is correct.This PR adds a hard assertion at the sink so the contract is enforced at the lowest level. Without it, a future caller refactor that drops the
Pid > 0check would silently hangWSLCProcess::Waitforever, because Docker never emitsexec_diefor a process that never spawned.Change
Suggested by @OneBlue in the #40550 review.