Concurrent Windows stops can escalate descendant cleanup before root shutdown completes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start with pkg/process/os_executor_windows.go and the shared tree-stop logic in pkg/process/os_executor.go, then read the existing Windows concurrent-stop test. Reproduce or extend coverage to distinguish native root exit from stdio-drain completion, including graceful and forced roots and descendant-held pipes. Done means the test establishes the intended descendant-escalation ordering while preserving stop ownership and bounded cancellation.
Written by the indexing model from the issue text.
Description
Summary
Follow-up to PR #278, reviewed at c49750ffc674334831dd2b00ac807987fd2432d4. This is not a blocker for that PR; improving the sequencing is deferred because the practical impact is narrow and a safe change must preserve the separation between process exit and output draining.
Current behavior
In pkg/process/os_executor_windows.go:113–120, a caller that does not own stopping waits for descendants, but returns immediately for the root (optWaitForStdio is set):
if !shouldStopProcess && (opts&optIsResponsibleForStopping) == 0 {
if (opts & optWaitForStdio) == 0 {
// Another stop owns signaling, but descendants must still be confirmed exited.
waitErr := waitForTrackedProcessExit(ctx, handle.Pid, ws, 0)
return singleProcessStopResult{waitEndedCh: waitEndedCh}, waitErr
}
return singleProcessStopResult{waitEndedCh: waitEndedCh}, nil
}
The shared tree-stop implementation uses the returned result to decide whether to begin graceful descendant cleanup:
forceDescendants := rootResult.forceKillUsed || rootStopErr != nil || graceCtx.Err() != nil
if len(tree) > 0 && !forceDescendants {
// Begin descendant cleanup under the graceful context.
}
See pkg/process/os_executor.go:715–738. Because the joining root call returns no error and no force-kill indication, it can begin descendant cleanup while the owning caller is still waiting for the root to shut down.
For descendants whose console-event receipt is unknown, Windows normally allows a six-second passive wait before force termination. An overlapping caller can therefore start that wait early and terminate descendants while the root is still within its own 15-second graceful window. Explicit stopping overlapping process-context cancellation is one possible entry point.
Impact and confidence
The practical concern is interrupted coordinated shutdown: the root may still be arranging child shutdown when the joining caller force-kills those children, potentially cutting off their cleanup or final output. The joining caller can also time out waiting for the root while the owning stop continues.
This is not immediate force termination, and it does not directly shorten the root owner's graceful wait. This particular ownership path requires overlapping stops on the same executor. Identity validation and final exit confirmation remain in place; no wrong-process termination, false successful cleanup, or process leak has been demonstrated from this behavior.
The sequencing was verified through code inspection, not a local Windows runtime reproduction. The Windows concurrent test deliberately starts descendant stopping before releasing its gated root, so the behavior is accommodated by existing coverage rather than being entirely untested.
Follow-up direction
Determine whether concurrent Windows stops should enforce the shared root-first contract, and implement any change without waiting for output draining before descendant cleanup. A simple copy of the Unix non-owner wait is insufficient as a complete proposal: cmd.Wait() can remain blocked after root exit because descendants retain stdout/stderr pipes. The historical tree-stop design intentionally defers that completion until after descendant cleanup.
Use existing identity-aware process-exit inspection where appropriate, preserve bounded cancellation and stop ownership, and propagate the owner's force-kill outcome if needed. Cover graceful and forced roots, overlapping explicit/cancellation cleanup, and descendant-held output pipes. The regression test should distinguish native root exit from stdio-drain completion and explicitly establish the intended descendant-escalation ordering.
- Dominant language
- Go
- Stars
- 191
- Forks
- 26
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 23
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/dcp
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Add application iconOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
API server: creating an Executable hangs 30-45 s (504) while the log storage restarts its parent resource watcher for ExecutablesPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 45/100
microsoft/dcp#286 · 6 comments · 1 assignee ·
Maintainers usually reply within 1 day
-
Disable DeleteCollection for DCP resourcesPossibly taken @TJ2005 claimed this 4 days ago. Open
Difficulty 3/5 1-2 days Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
microsoft/dcp#206 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
Similar issues
-
raised-by:verifier
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
medici-finance/assay#2718 ·
Maintainers usually reply within 1 day
-
connector good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
soma-intelligence/open-health-sync#60 ·
Maintainers usually reply within 1 day
-
automation models
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/TypeScript#64758 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
SocialGouv/iterion#2369 ·
Maintainers usually reply within 1 day