Repository navigation
Description
Describe the bug
Runner.Worker runs job steps in the same process group as Runner.Listener and whatever supervises it. When that group is orphaned, as it is on hosted macOS runners, a step can get the runner killed. The kernel sends SIGHUP and SIGCONT to the whole group, so Runner.Listener and hosted-compute-agent die. The job then ends with "The hosted runner lost communication with the server", step timeouts never fire and the logs are lost.
Process ancestry of a step shell on hosted macos-latest. The third column is the process group ID (pgid):
1908 1002 967 runner /bin/bash -e /Users/runner/work/_temp/....sh
1002 997 967 runner .../Runner.Worker spawnclient 143 146
997 980 967 runner .../Runner.Listener run
980 967 967 runner /opt/hca/hosted-compute-agent
967 1 967 runner /bin/bash /opt/hca/start_hca.sh
The group leader's parent is launchd, so the group is orphaned. If a member exits while another member is stopped, POSIX has the kernel send SIGHUP followed by SIGCONT to every process in the group. .NET's Process.Kill(entireProcessTree: true) SIGSTOPs each process before killing it, which is enough to trigger this. Within about 40 ms of the call, every process in the group received SIGHUP, SIGCONT and SIGTERM. We logged these with signal handlers in the app and with trap in a sibling shell.
To Reproduce
repro.cs:
using System.Diagnostics;
for (var i = 1; i <= 200; i++)
{
using var p = Process.Start(new ProcessStartInfo("/bin/sh", ["-c", "sleep 60 & sleep 60; wait"]) { RedirectStandardOutput = true })!;
Thread.Sleep(300);
p.Kill(entireProcessTree: true);
p.WaitForExit();
}
Console.WriteLine("completed 200 iterations");Workflow:
jobs:
repro:
runs-on: macos-latest
timeout-minutes: 8
steps:
- uses: actions/checkout@v5
- uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- run: dotnet run repro.csRun in the shared group, this killed the runner in 10 of 13 jobs. The same repro run in its own session and process group (os.setsid() before exec) passed 3 of 3, with the runner still alive.
Expected behavior
The worst a step should be able to do is fail or hang itself, so the step timeout fires and the logs are uploaded. Signals sent to a step's process group, whether by a tool or by the kernel, should not reach Runner.Listener or its supervisor.
Runner Version and Platform
The runner shipped in hosted macos-26-arm64 image 20260907.0351.1 (macOS 26.6.2), and also in macos-15 arm64. The steps used .NET runtime 10.0.12.
The cause is not specific to macOS. Any runner without a controlling terminal whose process group is orphaned has the same layout.
What's not working?
"The hosted runner lost communication with the server". The job runs until the job timeout.
Job Log Output
None. The runner is killed before the logs are uploaded.
Runner and Worker's Diagnostic Logs
Not available from hosted runners. A root-owned watchdog outside the group captured process tables before and after, a system-wide spindump and signal logs: https://github.com/thomhurst/ModularPipelines/releases/tag/diag-runtime-131944
Workflow and repro: https://github.com/thomhurst/ModularPipelines/tree/diag/macos-runner-loss/diag
Related
- macOS arm64 VMs freeze completely when a process tree is killed with .NET's Process.Kill(entireProcessTree: true) runner-images#14833, closed as a terminal freeze; the comments there show it is the runner being killed
- Process.Kill can hang indefinitely on macOS arm64 dotnet/runtime#131944, the .NET side, which should also avoid triggering this
- Proposed fix: Run Runner.Worker in its own process group when there is no terminal #4774
Activity