Skip to content

init aborts (SIGABRT) when an interop client disconnects before its reply: wil::ResultException Broken pipe inside wil::scope_exit in the Interop thread #41592

Closed

Description

Environment

  • WSL 2.7.11.0, kernel 6.18.33.2-microsoft-standard-WSL2, WSLg 1.0.73.2
  • Windows 10.0.26200.9445
  • Ubuntu distro with [boot] systemd=true

What happens

The distro's init (init-systemd(Ubuntu), PID 2 inside the pid namespace) dies with SIGABRT. Afterwards every new wsl.exe -d Ubuntu session fails immediately with Wsl/Service/E_UNEXPECTED, interop calls from inside the distro hang, VS Code Remote loops on reconnect; systemd inside the distro keeps running. Only wsl --terminate Ubuntu recovers.

Three occurrences in 24 hours, identical crash dumps (%LOCALAPPDATA%\Temp\wsl-crashes\wsl-crash-*-2-_init-6.dmp, "pid: 2, executable: !init, signal: 6"). dmesg each time:

WSL (2 - Interop) ERROR: SendMessage:182: Failed to write message LxMessageResultBool. Channel: InteropServer
libc++abi:
terminating due to uncaught exception of type wil::ResultException: Broken pipe @C:/__w/1/s/src/shared/inc\SocketChannel.h:183 (SendMessage)
init: Interop: potentially unexpected fatal signal 6.
WSL (8531 - CaptureCrash): Capturing crash for pid: 2, executable: !init, signal: 6, port: 50005

One of the three additionally logged, right before the abort:

WSL (2 - Interop) ERROR: CreateLoginSession:2758: Timed out waiting for user session for uid=0

Where in the source (main as of 2026-09-11, eaa69e7)

src/linux/init/config.cpp, ConfigHandleInteropMessage, case LxInitMessageCreateLoginSession:

bool success = false;
auto sendResponse = wil::scope_exit([&]() { Transaction.SendResultMessage<bool>(success); });
...
success = CreateLoginSession(Config, ..., CreateSession->Uid);

CreateLoginSession can block for up to boot.initTimeout (10 s default) polling systemctl is-active user@<uid>.service, on the single "Interop" worker thread. If the client (the session leader /init that wsl.exe started) has gone away meanwhile because the Windows-side caller timed out or was killed, SendResultMessage throws wil::ResultException (EPIPE). It throws from inside the wil::scope_exit lambda, whose destructor is noexcept, so the surrounding try { ... } CATCH_LOG() never sees it and std::terminate takes the whole init down.

The Interop thread is also single and unbounded: for (;;) { Accept; ReceiveTransaction; ReceiveOrClosed; handle } with no receive timeout, so one stalled client (in our case a process throttled by a cgroup memory.high limit) queues every other session start behind it, which is what makes callers give up and close their end.

Reproduction

  1. wsl --terminate Ubuntu
  2. Make the first root session slow, for example a systemd that needs more than 10 s to reach [email protected] (we had Startup finished in 18.6s), or any load that delays it.
  3. From PowerShell: $j = Start-Job { wsl -d Ubuntu -u root -e true }; Wait-Job $j -Timeout 3; Stop-Job $j
  4. When CreateLoginSession times out (or merely finishes) and writes its bool result, init aborts and the distro is unusable until terminated.

Suggested fix

  • Send the result inside the try body instead of from a wil::scope_exit, or wrap the send in the lambda with a CATCH_LOG(); a client that hung up must not take init with it.
  • Ideally, bound ReceiveTransaction / ReceiveOrClosed on the Interop server socket with a timeout, so one stalled client cannot block every other session start.

Mitigation we use meanwhile (for others hitting this)

loginctl enable-linger root (and for the default user), so user@<uid>.service is active before the first session and CreateLoginSession returns at once; keep systemd's boot under boot.initTimeout; never wrap wsl.exe -d ... in a kill-on-timeout.

Activity

  1. github-actions commented on Sep 12, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. chemwolf6922 commented on Sep 14, 2026

    @chemwolf6922
    Contributor

    Hi Davide (@blackdiamond6390) .
    The scope_exit throw issue was fixed in #40691. And the zombie distro state was fixed in #40433. Both are in the pre-release versions. And not backported to 2.7.x. If possible, please update to the latest pre-release version. Thanks.

    However, the trigger of the issue is still not clear. (Why did the sendMessage fail). Please try capture the repro with the log collection script if possible. That will help solve that part.

  3. meisenbraun commented on Sep 19, 2026

    @meisenbraun

    Hitting this in the wild, twice in three days. The trigger was the OpenAI Codex desktop app, not a synthetic repro.

    Environment: Windows 11, WSL2 kernel 6.6.114.1-microsoft-standard-WSL2, Ubuntu with systemd=true. The default user (uid 1000) has linger enabled and [email protected] is already active, so this doesn't depend on a slow first login.

    Signature (identical both times, 2026-09-16 18:50:42 and 2026-09-18 20:47:30):

    WSL (2 - Interop) ERROR: SendMessage:182: Failed to write message LxMessageResultBool. Channel: InteropServer
    libc++abi: terminating due to uncaught exception of type wil::ResultException: Broken pipe @C:/__w/1/s/src/shared/inc\SocketChannel.h:183 (SendMessage)
    kernel: init: Interop: potentially unexpected fatal signal 6.
    

    Effect: the Interop worker never comes back. Sessions that are already open keep working, but until the distro is terminated:

    • every new wsl.exe -d Ubuntu -- <cmd> from Windows hangs indefinitely
    • every Linux-to-Windows launch (cmd.exe /c ver) fails with UtilAcceptVsock:273: accept4 failed 110
    • wsl.exe -l -v still reports the distro as Running, which makes this hard to diagnose

    Trigger: the Codex desktop app runs git operations against a WSL project by starting many wsl.exe processes at once (its crash-reporter breadcrumbs show about 20 within 200 ms) and killing the ones that don't finish in time. A UI action in Codex came 6 s before the crash. That's the same "client disconnects before the reply" condition as your PowerShell-timeout repro, but from a real-world client.

    Because of the single-threaded worker, a burst of concurrent session creations queues up, so a client-side timeout is much more likely to fire before its reply arrives. One such disconnect takes down interop for the whole distro until wsl --terminate.

    Request: handle a failed SendResultMessage without terminating (the throw inside the noexcept scope_exit is the direct cause), and ideally restart the Interop worker if it dies.

  4. chemwolf6922 commented on Sep 21, 2026

    @chemwolf6922
    Contributor

    Hi Matthew Eisenbraun (@meisenbraun) . If possible, please try capture the repro with the collect-wsl-logs script and share the log. Thanks.

  5. microsoft-github-policy-service commented on Sep 28, 2026

    @microsoft-github-policy-service
    Contributor

    This issue has been automatically closed since it has not had any author activity for the past 7 days. If you're still experiencing this issue please re-file it as a new issue.

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions