Ben Hillis c13fe6488e Isolate plugins in an out-of-process COM host
WSL plugin DLLs are moved out of wslservice.exe into a separate
wslpluginhost.exe COM server so plugin code can no longer crash or
destabilize the service. Each plugin is activated in its own host
process (CLSCTX_LOCAL_SERVER, SYSTEM-only via AppID) and reached
through a versioned COM interface defined in WslPluginHost.idl. All
hosts are tied to a service-owned job object and terminate when
wslservice exits. The plugin API is unchanged; existing plugins run
unmodified.

A crashing or disconnected host is classified by IsHostCrash
(RPC_E_DISCONNECTED, RPC_E_SERVER_DIED[_DNE], CO_E_OBJNOTCONNECTED,
RPC_S_SERVER_UNAVAILABLE, RPC_S_CALL_FAILED[_DNE]); the service logs
it and continues instead of treating it as a fatal plugin error.
RPC_E_CALL_REJECTED is intentionally excluded as a transient busy
state rather than a dead host.

Plugin->service callbacks (MountFolder, ExecuteBinary, and the WSLC
session APIs) arrive on a different COM thread than the outbound hook,
so they cannot re-enter the lock held during the hook:
- VM path: LxssUserSessionImpl guards callbacks with a shared_mutex
  (shared for callbacks, exclusive in _VmTerminate after OnVmStopping
  drains in-flight callbacks before the utility VM is destroyed).
- WSLC path: PluginManager resolves sessions through its own
  reference map under a dedicated lock, and WSLCSessionManager
  releases its session lock before any plugin notification fires, so
  callbacks never re-enter the session lock. A session is registered
  in the reference map but not published until OnWslcSessionCreated
  succeeds, so a vetoed or race-lost session is never handed out.

Proxy/stub is consolidated into wslserviceproxystub.dll. One new exe,
no new DLLs.

Tests
- HostCrashIsolation: kills wslpluginhost.exe mid-OnVmStarted and
  verifies the service survives and m_initOnce stays sticky.
- ConcurrentCallbacks: four plugin threads hammer MountFolder and
  ExecuteBinary, exercising the shared callback lock.
- AsyncApiCallFromWorker: a plugin worker thread calls into the
  service post-hook (cross-apartment, non-COM-initialized).
- CallbacksDuringTerminationDoNotCrash: worker threads race
  _VmTerminate's exclusive lock and VM teardown, then wind down
  deterministically after OnVmStopping signals them and are joined on
  the next session start.
- Existing WSL1 plugin tests broadened alongside the refactor.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-29 17:15:34 +00:00

Welcome to the Windows Subsystem for Linux (WSL) repository

WSL logo

Learn more about WSL | Downloads & Release notes | Contributing to WSL

About

Windows Subsystem for Linux (WSL) is a powerful way for you to run your Linux command-line tools, utilities and applications, all unmodified and directly on Windows without the overhead of a traditional virtual machine or dual boot setup.

You can install WSL right away by running this command inside of your Windows command line:

wsl --install

You can learn more about best practices for setup, overviews of WSL and more at our WSL documentation page.

WSL also has related open source repositories:

Contributing

This project welcomes contributions of all types, including coding features / bug fixes, documentation fixes, design proposals and more.

We ask that before you start working on a contribution, please read our Contributor's Guide.

For guidance on developing for WSL, please read the developer docs for instructions on how to build WSL from source and details on its architecture.

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsofts Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-partys policies.

Privacy and telemetry

The application logs basic diagnostic data (telemetry). For more information on privacy and what we collect, see our data and privacy documentation.

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsofts privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

Description
Windows Subsystem for Linux
Readme MIT 110 MiB
2.5.10 Latest
2025-08-05 16:36:10 -05:00
Languages
C++ 69.2%
C 26.6%
C# 1.7%
CMake 1%
Python 0.8%
Other 0.6%