Repository navigation
Description
Brief description of your issue
The WSLc RAII guards WslcSessionGuard, WslcContainerGuard, and WslcProcessGuard
call SDK teardown functions (WslcTerminateSession/WslcReleaseSession,
WslcReleaseContainer, WslcReleaseProcess) in their Drop impls without entering
a COM apartment (ComApartment::enter()), unlike every other SDK entry point
(destroy/stop/wait_for_exit), which join the MTA for the call.
init_and_load_sdk initializes COM per-thread (COINIT_MULTITHREADED). On the
run-to-completion path this is harmless because spawn/wait/teardown all run on the one
thread that entered the apartment. But once the streaming SandboxBackend path is used,
the Send WslcSandboxProcess/Sandbox handle can be moved to and dropped on a thread
that never joined the MTA (e.g. a tokio spawn_blocking worker, or
wait_with_output(mut self) consuming and dropping on the waiting thread) — so heavy
session/container/process teardown runs on an apartment-less thread, contradicting the
unsafe impl Send for WslcSandboxProcess soundness argument
(src/backends/wslc/common/src/sandbox.rs:105-121).
Source: src/backends/wslc/common/src/wslc_bindings.rs:362-441.
Notes:
- AppContainer already fixed this same class: its
NetworkManagerused to cache an STA
COM interface and reuse it at teardown, and was reworked so each firewall op is
apartment-self-contained (src/backends/appcontainer/common/src/appcontainer_runner.rs:1388-1404).
Steps to reproduce
- Build with
--features wslcand enable the experimental streaming path. - Spawn a WSLc sandbox via the
mxc-sdkstreaming API (spawn_sandbox). - Move the returned handle to another thread (e.g. tokio
spawn_blocking, or call
wait_with_output) and let it drop there. - The guard
Dropimpls callWslcTerminateSession/WslcReleaseContainer/
WslcReleaseProcesson a thread that never entered the MTA apartment.
Expected behavior
SDK teardown always runs inside the multithreaded apartment the SDK was initialized
under — either by having the guards enter a ComApartment in Drop, or by tearing the
handles down explicitly inside an apartment scope before the guards drop (mirroring
destroy/stop and the AppContainer NetworkManager fix).
Actual behavior
The guard Drop impls call the SDK release/terminate functions with no ComApartment,
so on a cross-thread drop the teardown runs on an apartment-less thread.
Activity
github-actions commentedon Jul 31, 2026
Triage complete.
Issue-Bug,OS-Linux,Container-WSLC(already present — confirmed correct)This is a soundness bug in the WSLC backend:
WslcSessionGuard,WslcContainerGuard, andWslcProcessGuardDropimpls invoke SDK teardown functions without entering aComApartment, which is unsafe when the handle is dropped on a thread that never joined the MTA (e.g. viaspawn_blockingorwait_with_output). The fix should mirror the AppContainerNetworkManagerpattern — either enterComApartmentinDrop, or ensure explicit teardown always happens inside an apartment scope before the guards drop.Maintainers: Comment
/investigateto check whether this issue or bug is valid against the most current code. Copilot will also produce a report with the changes that will be needed. For a small, unambiguous documentation or test fix, it may also create one draft PR.github-actions commentedon Jul 31, 2026
Triage complete.
Issue-Bug,OS-Windows,Container-WSLC) are correct — no new labels added.@SohamDas2021(already assigned — WSLC / Linux backend owner).Needs-Triageremoved.The issue is a soundness bug in the WSLC RAII guard
Dropimpls:WslcSessionGuard,WslcContainerGuard, andWslcProcessGuardcall SDK teardown functions without entering aComApartment, which is unsafe when handles are dropped on threads that never joined the MTA (e.g. afterSend-ing across tokio threads or callingwait_with_output).Maintainers: Comment
/investigateto check whether this issue or bug is valid against the most current code. Copilot will also produce a report with the changes that will be needed. For a small, unambiguous documentation or test fix, it may also create one draft PR.SohamDas2021 commentedon Jul 31, 2026
Needs to go after #687
fix(wslc): join the MTA when releasing SDK handles on drop
fix(wslc): never call the WSLC SDK without a COM apartment
Make WSLC an available backend on the Rust SDK (#687)
SohamDas2021 commentedon Aug 10, 2026
Fixed in #687