WindowsSandboxServer.exe crashes (unhandled exception in ManagedWindowsVM.Terminate during VM teardown), killing the running guest
Summary
WindowsSandboxServer.exe (the broker/manager process) intermittently terminates
with an unhandled exception thrown from WindowsUdk.Security.Isolation.ManagedWindowsVM.Terminate()
during VM shutdown/teardown. Because the exception is unhandled on a thread‑pool /
event‑callback thread, the entire broker process crashes, which tears down the
running sandbox guest and blocks new launches until things are cleaned up. Reproduces
on long‑running / high‑throughput sandbox sessions.
Two exception variants are observed, both in the same Terminate() call path:
System.ObjectDisposedException: Cannot access a disposed object. Object name: 'ObjectReference'.
— Terminate() is invoked on a VM whose WinRT IObjectReference has already been disposed.
System.Runtime.InteropServices.COMException (0x800706BF): The remote procedure call failed and did not execute.
— the RPC to terminate the VM fails (VM already gone).
Environment
- Windows Sandbox package:
MicrosoftWindows.WindowsSandbox_0.8.107.0_x64__cw5n1h2txyewy (v0.8.107.0)
- Faulting module:
KERNELBASE.dll 10.0.26100.8875 · Exception code 0xe0434352 (managed) · Fault offset 0xc1ada
- Runtime: .NET 9.0.18 (CoreCLR 9.0.1826.31522)
- Host: Windows 11 (build 10.0.26100), Windows 365 Cloud PC (nested virtualization), 32 logical CPUs
- Workload: long batches of programmatic sandbox runs — each run maps host folders read‑only,
runs a build/test workload inside the guest, and the guest self‑shuts‑down (shutdown /s)
on completion. Crashes cluster around guest teardown.
Frequency
3 crashes captured over ~24h of on/off use (Application/.NET Runtime event 1026 +
Application Error 1000). All three fault at the identical offset in the same
Terminate() path. WER Report IDs: d915b65c-…, 6c131bcd-…, feb03924-….
Stack traces
Variant 1 — ObjectDisposedException (2 of 3 occurrences)
System.AggregateException: One or more errors occurred. (Cannot access a disposed object. Object name: 'ObjectReference'.)
---> System.ObjectDisposedException: Cannot access a disposed object. Object name: 'ObjectReference'.
at WinRT.IObjectReference.<ThrowIfDisposed>g__ThrowObjectDisposedException|47_0()
at WinRT.IObjectReference.get_ThisPtr()
at ABI.WindowsUdk.Security.Isolation.IManagedWindowsVMMethods.Terminate(IObjectReference _obj)
at WindowsUdk.Security.Isolation.ManagedWindowsVM.Terminate()
at SandboxServer.VM.SandboxVM.Shutdown()
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(...)
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at System.Threading.Tasks.Task.Wait()
at SandboxServer.VM.SandboxVMCreator.<>c__DisplayClass4_0.<Create>b__0(Object sender, EventArgs args)
at System.Diagnostics.Process.RaiseOnExited()
at System.Diagnostics.Process.CompletionCallback(Object waitHandleContext, Boolean wasSignaled)
at System.Threading.RegisteredWaitHandle.PerformCallback(Boolean timedOut)
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Variant 2 — COMException 0x800706BF (RPC failed) (1 of 3 occurrences)
System.Runtime.InteropServices.COMException (0x800706BF): The remote procedure call failed and did not execute.
at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|38_0(Int32 hr)
at ABI.WindowsUdk.Security.Isolation.IManagedWindowsVMMethods.Terminate(IObjectReference _obj)
at WindowsUdk.Security.Isolation.ManagedWindowsVM.Terminate()
at SandboxServer.VM.SandboxVM.Shutdown()
at SandboxServer.VM.SandboxVM.Dispose()
at SandboxServer.VM.SandboxManager.OnVmTerminated(Object sender, EventArgs args)
at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
at System.Threading.QueueUserWorkItemCallback.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
Analysis
Both variants are a VM‑lifecycle teardown race: SandboxVM.Shutdown() calls
ManagedWindowsVM.Terminate() on a VM that is already being disposed / already gone —
- reached via the VM process's
Process.Exited handler (SandboxVMCreator.<Create>b__0)
racing with disposal → ObjectDisposedException, or
- reached via
SandboxVM.Dispose() → SandboxManager.OnVmTerminated after the VM RPC
endpoint is already torn down → COMException 0x800706BF.
In both cases the exception propagates unhandled on a thread‑pool/callback thread and
crashes the whole broker (rather than being caught and treated as "already terminated").
Suggested fix
Treat "the VM is already gone" as a no‑op during teardown: guard/try‑catch around
ManagedWindowsVM.Terminate() (and the IObjectReference access) in SandboxVM.Shutdown()
/ the Process.Exited and OnVmTerminated handlers, swallowing ObjectDisposedException
and COMException (0x800706BF) (RPC_S_CALL_FAILED_DNE) since the VM is already terminated.
Impact / workaround
Any programmatic/long‑running use of Windows Sandbox is exposed: a mid‑workload crash
kills the guest and loses in‑flight work. Workaround used here is to make the workload
resumable so a crash only costs in‑flight items — but the broker crash itself is the
underlying bug.
WindowsSandboxServer.exe crashes (unhandled exception in ManagedWindowsVM.Terminate during VM teardown), killing the running guest
Summary
WindowsSandboxServer.exe(the broker/manager process) intermittently terminateswith an unhandled exception thrown from
WindowsUdk.Security.Isolation.ManagedWindowsVM.Terminate()during VM shutdown/teardown. Because the exception is unhandled on a thread‑pool /
event‑callback thread, the entire broker process crashes, which tears down the
running sandbox guest and blocks new launches until things are cleaned up. Reproduces
on long‑running / high‑throughput sandbox sessions.
Two exception variants are observed, both in the same
Terminate()call path:System.ObjectDisposedException: Cannot access a disposed object. Object name: 'ObjectReference'.—
Terminate()is invoked on a VM whose WinRTIObjectReferencehas already been disposed.System.Runtime.InteropServices.COMException (0x800706BF): The remote procedure call failed and did not execute.— the RPC to terminate the VM fails (VM already gone).
Environment
MicrosoftWindows.WindowsSandbox_0.8.107.0_x64__cw5n1h2txyewy(v0.8.107.0)KERNELBASE.dll10.0.26100.8875 · Exception code0xe0434352(managed) · Fault offset0xc1adaruns a build/test workload inside the guest, and the guest self‑shuts‑down (
shutdown /s)on completion. Crashes cluster around guest teardown.
Frequency
3 crashes captured over ~24h of on/off use (Application/.NET Runtime event 1026 +
Application Error 1000). All three fault at the identical offset in the same
Terminate()path. WER Report IDs:d915b65c-…,6c131bcd-…,feb03924-….Stack traces
Variant 1 — ObjectDisposedException (2 of 3 occurrences)
Variant 2 — COMException 0x800706BF (RPC failed) (1 of 3 occurrences)
Analysis
Both variants are a VM‑lifecycle teardown race:
SandboxVM.Shutdown()callsManagedWindowsVM.Terminate()on a VM that is already being disposed / already gone —Process.Exitedhandler (SandboxVMCreator.<Create>b__0)racing with disposal →
ObjectDisposedException, orSandboxVM.Dispose()→SandboxManager.OnVmTerminatedafter the VM RPCendpoint is already torn down →
COMException 0x800706BF.In both cases the exception propagates unhandled on a thread‑pool/callback thread and
crashes the whole broker (rather than being caught and treated as "already terminated").
Suggested fix
Treat "the VM is already gone" as a no‑op during teardown: guard/try‑catch around
ManagedWindowsVM.Terminate()(and theIObjectReferenceaccess) inSandboxVM.Shutdown()/ the
Process.ExitedandOnVmTerminatedhandlers, swallowingObjectDisposedExceptionand
COMException (0x800706BF)(RPC_S_CALL_FAILED_DNE) since the VM is already terminated.Impact / workaround
Any programmatic/long‑running use of Windows Sandbox is exposed: a mid‑workload crash
kills the guest and loses in‑flight work. Workaround used here is to make the workload
resumable so a crash only costs in‑flight items — but the broker crash itself is the
underlying bug.