microsoft / microsoft/WSL

wslservice stuck in stopping state & wsl --shutdown shows the error as OOM

Open
#41,449 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

emailed-logs wslc
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

Windows Version

Microsoft Windows [Version 10.0.26310.28089]

WSL Version

2.9.9.0

Are you using WSL 1 or WSL 2?
  • WSL 2
  • WSL 1
Kernel Version

No response

Distro Version

6.18.40.1-1

Other Software

Not related

Repro Steps

This is not a deterministic issue. This was found during development. Where wsl --shutdown always returns

Not enough memory resources are available to complete this operation.
Error code: Wsl/E_OUTOFMEMORY

The original trigger is not captured.

Expected Behavior

wsl shuts down normally.

Actual Behavior

The error has two folds:

  1. The service stuck in the stopping state
    The wsl VM was stopped. But the wslc VM was not. Initial analysis shows this could be a dead lock in the wslc shutdown logic.

  2. The wsl --shutdown call translates the stopping state to OOM.
    https://github.com/microsoft/WSL/blob/00df65ad829adcdcbe0cb82af5179f67f6234464/src/windows/service/exe/LxssUserSessionFactory.cpp#L168-L174
    This logic here translates the stopping state to S_FALSE. And the function is returned with S_FALSE and ppCreated = NULL. This may have caused COM to treat this as an OOM. There was system memory pressure during the repro.

Diagnostic Logs

Captured wsl log and wsl service dumps were emailed.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/windows/service/exe/LxssUserSessionFactory.cpp at lines 168-174 and trace how the stopping state is returned through wsl --shutdown. Reproduce the wslc shutdown deadlock and OOM translation if possible, using the issue's WSL logs and service dumps as references. Done means shutdown completes normally and does not report the stopping state as E_OUTOFMEMORY.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.