Repository navigation
Description
Description
On macOS arm64, Process.Kill(entireProcessTree: true) can block indefinitely while terminating process trees created by the dotnet-watch tests.
This appeared after consuming the runtime flow containing #128598, which introduced the two-phase stop-then-kill implementation on Unix.
Enable dotnet-watch tests on mac once fixed: dotnet/sdk#55679
Reproduction Steps
-
From a
dotnet/sdkcheckout at commitdc6cef6, run thedotnet-watch.Testssuite on macOS 15 arm64. In CI, this is Helix sharddotnet-watch.Tests.dll.2on queueosx.15.arm64.open. -
Allow tests to dispose their child processes using
Process.Kill(entireProcessTree: true). -
Observe that some calls never return.
A standalone runtime-only reproduction has not yet been reduced. The failure reproduces in the SDK CI shard linked below.
Expected behavior
Process.Kill(entireProcessTree: true) terminates the process tree and returns promptly.
Actual behavior
Instrumentation logged nine calls entering Process.Kill(entireProcessTree: true), but only three returned. Helix eventually detected the hang, collected dumps, and terminated the test process:
[TEST AwaitableProcess.cs:237] Killing process tree for process 18251
Hang dump timeout of '00:48:00' expired
Test application process didn't exit gracefully, exit code is '137'
One separate call returned from Kill, but its process still did not exit within 30 seconds.
Regression?
Observed after the SDK consumed the runtime flow containing #128598. That PR changed Unix process-tree termination to recursively stop the tree before killing it.
Confidence is high that the immediate hang occurs synchronously inside Process.Kill(entireProcessTree: true). Confidence that #128598 introduced the regression is moderate pending a reduced runtime-only reproduction.
Known Workarounds
None currently. Bounding the subsequent wait does not help because the call to Process.Kill itself does not return.
Configuration
- macOS 15
- arm64
- Helix queue:
osx.15.arm64.open - Work item:
dotnet-watch.Tests.dll.2 - .NET 11 runtime consumed by the SDK flow
Other information
- SDK Known Build Error: [macOS arm64] dotnet-watch cleanup hangs in Process.Kill(entireProcessTree: true) sdk#55636
- Failing build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1542039
- Helix job: https://helix.dot.net/api/jobs/2393a91c-17df-4ae9-b32c-faab6d292cf1/details
- Suspected runtime change: Fix Process.Kill(entireProcessTree: true) when intermediate child has KillOnParentExit #128598
Activity
dotnet-policy-service commentedon Aug 6, 2026
Tagging subscribers to this area: @dotnet/area-system-diagnostics-process
See info in area-owners.md if you want to be subscribed.
adamsitnik commentedon Aug 11, 2026
Hi @mthalman
Thank you for a detailed bug report. I've hit hangs on macOS in #128598 but I was able to find the solution (#128598 (comment)) and get the dotnet/runtime CI green. Since then it never got stuck on macOS.
Were you able to collect a dump locally? Or at least attach a debugger and just check which methods exactly are blocked?
Do you happen to know if
dotnet-watch.Tests.dll.2does something unusual in terms of process management like p/invoking some native code that signs up for the SIGCHILD?I am asking these questions because I don't have an access to macOS arm64 machine (I will somehow try to get it, but it may take some time).
mthalman commentedon Aug 11, 2026
This happens in Helix. I don't know much about Helix so I don't know if they capture a dump or not. But an example build is at https://dev.azure.com/dnceng-public/public/_build/results?buildId=1542039. The hang seems to be sporadic.
Add macOS-only repro for dotnet/runtime#131944 with watchdog and CI
adamsitnik commentedon Aug 20, 2026
My mac is useless as I can't netiher build dotnet/runtime nor run the installed dotnet executable (it's simply too old and not supported). I've tried creating a standalone repro, but I've failed to reproduce the problem: https://github.com/adamsitnik/macosrepro
I suspect dotnet watch does something unusual that interferes with signal handling. I'll try to search for someone to try to debug it who has a working mac.
Proactively drain non-exit notifications for tracked pids on macOS
Fix macOS drain: TryReapChild cannot observe a plain job-control stop
slang25 commentedon Oct 3, 2026
Hi @adamsitnik, I think I've hit the same thing (or a close cousin of it), and I've got a small standalone repro that fails reliably on GitHub-hosted macOS runners, so hopefully that helps since getting hold of a mac is the hard part 🙂
The twist on GitHub's runners is that it isn't just the call that blocks, the whole VM freezes. The runner loses contact with GitHub, step timeouts never fire, no logs get uploaded, and a root-owned process I left running as a canary stopped reporting at the same moment. Memory, network and file handles all looked healthy right up until it stopped.
Repro
repro.cs:Workflow:
Expected: 200 iterations, done in about a minute.
Actual: the job never finishes and gets killed at the job timeout. That happened 4/4 times (2×
macos-26, 2×macos-15, both arm64): https://github.com/slang25/glosharp/actions/runs/37140854273. It only takes the first few iterations, and the same loop runs all 200 iterations fine on my own Apple silicon mac (macOS 26), so it seems to be specific to the VMs.What I tried
I swapped
Kill(entireProcessTree: true)for other things in the same loop (https://github.com/slang25/glosharp/actions/runs/37138500101, https://github.com/slang25/glosharp/actions/runs/37139476351):Kill(entireProcessTree: true)Kill()Process.GetProcesses()kill(SIGSTOP)thenkill(SIGKILL)via P/Invokekill(SIGSTOP), enumerate all processes, thenkill(SIGKILL)ps -A -o pid=,ppid=snapshot, thenkill(SIGKILL)eachSo it seems to need the full recursive stop/enumerate/kill, which I couldn't reproduce by hand. One thing that might be relevant to the regression label: we first saw this with our test host on .NET 8 and the repro above runs on .NET 10, so I don't think it's only #128598. I could be wrong about that though, I haven't tried a .NET 11 build.
Images:
macos-26-arm6420260907.0351.1 (macOS 26.6.2) andmacos-15arm64.For now we've worked around it on macOS by killing the descendants from a
pssnapshot instead: slang25/glosharp#117. Happy to run anything else on those runners if it'd help.Add polyglot hosting integrations through ATS projection (#16110)
thomhurst commentedon Oct 12, 2026
We hit this in ModularPipelines and can add another data point. It reproduces on shipped .NET 10, not just the .NET 11 flow.
Environment: GitHub-hosted
macos-latest(macos-26-arm64image 20260907.0351.1), runtime 10.0.12 osx-arm64 installed byactions/setup-dotnet.Real-world impact: our command runner calls
Process.Kill(entireProcessTree: true)when a cancelled command outlives its graceful-shutdown window. Our core unit tests do that many times. Since 2026-09-28 the macOS CI job froze in about 1 run in 5 (20 of 22 failed runs in one week). It always froze during the test run, and the runner reported "The hosted runner lost communication with the server". A sampler running outside the runner's process group, posting every second, showed about 81% of memory free, no swap use and a stable process count right up to the freeze.Repro, same loop as @slang25's above (200 iterations, kill a
sh -c "sleep 60 & sleep 60; wait"tree), run 38252153698:Kill(entireProcessTree: true)proc_listchildpids, thenKill()the root and each descendantThe second row matches @slang25's finding that per-process kills from a snapshot are safe. We've shipped it as a workaround on macOS (thomhurst/ModularPipelines#5927). Happy to run instrumented builds on hosted runners if that helps narrow it down.
thomhurst commentedon Oct 12, 2026
Follow-up with captures from hosted
macos-latest(runtime 10.0.12). It isn't a freeze. Every process in the caller's process group gets signalled.On these runners the whole job shares one process group, led by
/bin/bash /opt/hca/start_hca.sh:start_hca.sh→hosted-compute-agent→Runner.Listener→Runner.Worker→ step shell → the test app. Within ~40 ms of the firstKill(entireProcessTree: true), every process in that group receivesSIGHUP,SIGCONTandSIGTERM. We logged these withPosixSignalRegistrationin the app andtrapin a sibling shell:Runner.Listenerandhosted-compute-agentare gone, which is why the job "loses communication". A process table captured by a root watchdog outside the group shows the whole group gone, while ~270 other processes owned by the same user survive.setsidpassed 3 of 3, 200 iterations each, runner alive. On a dev machine the terminal puts each command in its own group, which would explain why it never reproduces there.SIGSTOPlooks like the trigger:SIGHUPfollowed bySIGCONTmatches the orphaned-process-group rule, where the kernel signals a group that becomes orphaned while it has stopped members.KillTreeSIGSTOPs each process before killing it. A snapshot of descendants followed by a plainSIGKILLof each process never triggers it (0 of 3, and 0 of 15+ in our CI). We haven't found where theSIGTERMcomes from; it may be the runner agent shutting down its group after theSIGHUP.KillTree(stop, enumerate, kill, recurse), not the Fix Process.Kill(entireProcessTree: true) when intermediate child has KillOnParentExit #128598 rewrite.Captures (process tables before and after, system-wide
spindump, watchdog logs, heartbeats): https://github.com/thomhurst/ModularPipelines/releases/tag/diag-runtime-131944. Workflow and repro: https://github.com/thomhurst/ModularPipelines/tree/diag/macos-runner-loss/diag. A heap dump isn't possible because the app is killed before anything can attach.fix(commands): avoid runtime process tree kill on macOS and log every…
Kill process tree descendants before ancestors on Unix (#135624)
adamsitnik commentedon Oct 13, 2026
I need to keep this issue opened until we get #135409 backported to 11 and prepare the fix for 10 as well (I am going to take care of that).
[release/11.0] Fix macOS Process hangs caused by stopped children (#1…
Update to .NET 11 RC2 (#3340)
Speed up eng/update-all.cs
Update to .NET 11 RC3
Update to .NET 11 and Meziantou.NET.Sdk 1.0.199 (#4838)