Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2 distro dies when the PC is sleeping #8763

Open
1 of 2 tasks
speller opened this issue Aug 25, 2022 · 26 comments
Open
1 of 2 tasks

WSL2 distro dies when the PC is sleeping #8763

speller opened this issue Aug 25, 2022 · 26 comments

Comments

@speller
Copy link

speller commented Aug 25, 2022

Version

Microsoft Windows [Version 10.0.22621.382]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

5.15.57.1

Distro Version

Ubuntu-20.04

Other Software

No response

Repro Steps

The bug is floating. Regularly, but not always, I found all WSL2 apps in the Ubuntu distro have been killed while the PC was asleep. Docker Desktop usually survives. Opened shell windows in the Ubuntu distro exit with an error status.

Expected Behavior

All apps are working when waking from sleep.

Actual Behavior

Sometimes apps are killed.

Diagnostic Logs

How to see logs right when the issue happened, without turning logs on permanently for days?

@tmonczko
Copy link

Unfortunately I don't have any more specific information to contribute either, but I've also noticed this issue in the last two weeks (have been using WSL2 for two years to date).

Sometimes on waking up Windows from sleep, all WSL tabs in Windows Terminal are still open, but WSL has stopped and all tabs are frozen. To get things going again, I have to run wsl --shutdown from PS, then wsl to start it up again. I'll keep a close eye on it to try to get some more details!

This is a separate issue from the linux clock going out of sync when Windows goes to sleep.

@argo-wayneb
Copy link

I am also seeing this daily on a Dell XPS15, running Windows 11 Business 21H2 (22000.1165) (Windows Feature Experience Pack 1000.22000.1165.0). For me, Windows Terminals with WSL stuff running in them hang (unresponsive to typing), VSCode using WSL "remote" environments all hang and try to reconnect to no avail. New WSL terminals fail to start (they just open a new terminal and hang).

I also see this process spinning in the Task Manager:

image

Also, wsl --shutdown and wsl --terminate "Ubuntu" just hang forever. A reboot (which takes ages presumably since Windows is waiting then eventually force-killing things) is the only solution for me. HELP! What is going on here? Why is it so unstable?

I have also used WSL2 for years and never seen this... Is it a Win11 thing?

@argo-wayneb
Copy link

While this usually happens when I wake up my laptop in the morning, I have also seen the hang happen mid-way through the day, too.

@speller
Copy link
Author

speller commented Nov 7, 2022

As a non-guaranteed workaround, I've disabled automatic Microsoft Store updates. I suppose they were a reason at least for some of the dies. Since that, I've updated Windows to the latest cumulative update and for a couple of weeks, I don't face this issue.

@argo-wayneb dies during the daytime work can be related to microsoft/wslg#678

@tmonczko
Copy link

tmonczko commented Nov 9, 2022

I updated Windows (11 Pro) to Version 10.0.22621 (i.e. version 22H2) (Build 22621) a few days ago and it seems to have fixed the problem for me. Interested to hear if it works for others.

@thecharlesjenkins
Copy link

thecharlesjenkins commented Dec 6, 2022

I have been having this problem since I updated to "2022-11 Cumulative Update for Windows 11 Version 22H2 for x64-based Systems (KB5020044)" 3 days ago. WSL (and all applications using WSL) crash after my computer wakes from sleep and requires a full reboot.

@BenjaVR
Copy link

BenjaVR commented Feb 20, 2023

I face this issue almost every morning with my laptop running the latest stable Windows 11. On my desktop (latest insiders builds) I do not have this issue however...

This command (elevated PS prompt) fixes it for me: taskkill /f /im wslservice.exe. Usually I have to restart apps using WSL as well (Docker, JetBrains IDEs ...).

@VOID07
Copy link

VOID07 commented Mar 11, 2023

I've been facing this issue, too, more frequently after upgrading to W11,
It requires restarting the whole pc as it does not work trying to kill the service or the process, WSL just freezes.
When trying to stop the service, it returned 1053 the service did not respond to the start or control request in a timely fashion

This also happens overnight or whenever the PC sleeps for more than 30 minutes or so.

I've just downgraded to WSL 1 in hopes it removes the issue, I will let you know if it does.

@QAnders
Copy link

QAnders commented Mar 23, 2023

This started happening to me too last few days and now seems to happen after every night (or longer time away from the laptop). Running on a Dell XPS 17 with Win 11 21H2 22000.1696, WSL2 Ubuntu 22.04.2.

I am using Windows Terminal, have a few tabs open and everything is fine. I leave my laptop so that it sleeps or hibernate it and when logging back in the Terminal window has closed.
VSCode has also lost all connection to QSL and "hangs".

If I open it it just hangs and no prompt comes up. Any wsl command in PS just hangs, the only solution is to restart the laptop (which is extremally annoying as I have a few databases and Docker containers to spin up again before I can resume work...)

Same as @thecharlesjenkins, I have two 2022-11 Cumulative Update for Windows 11 (KB5023698 and KB5022836) and the timing is about right for when this started...

EDIT: I wonder if it has some connection to Docker... If I don't have Docker running it seems as if it is not happening, and I also got a "crash" when starting a few new containers and I got [process exited with code 1 (0x00000001)] in all open tabs as the containers started up...

@Seosaidh
Copy link

Seosaidh commented Mar 24, 2023

You can add me to the list of people with this same problem. It started a few weeks ago. While building a Linux application via WSL/Visual Studio, it will randomly hang and I have to reboot, as any powershell wsl commands just hang forever.
Back in February (or maybe earlier) it was working just fine.

This will happen to me multiple times per day.

@QAnders
Copy link

QAnders commented Mar 24, 2023

This has gotten completely out of hand!

It now terminates WSL2 several times a day, also killing Docker desktop and VSCode.
Trying to restart things completely freezes the processes and only a restart will sort it.

Previously this happened after sleep or hibernate, but now it happens in the middle of working with the laptop.

@VOID07
Copy link

VOID07 commented Mar 25, 2023

I've been facing this issue, too, more frequently after upgrading to W11, It requires restarting the whole pc as it does not work trying to kill the service or the process, WSL just freezes. When trying to stop the service, it returned 1053 the service did not respond to the start or control request in a timely fashion

This also happens overnight or whenever the PC sleeps for more than 30 minutes or so.

I've just downgraded to WSL 1 in hopes it removes the issue, I will let you know if it does.

After downgrading to WSL 1, at least it shows the prompt when logging back. I might need to restart the service, but it does not hang.

@2pl
Copy link

2pl commented Jul 9, 2023

I have been facing a similar issue for a couple of weeks now.
Most likely linked to a windows patch as i didn't change wsl version for w while:

wsl --version
WSL version: 1.2.5.0
Kernel version: 5.15.90.1
WSLg version: 1.0.51
MSRDC version: 1.2.3770
Direct3D version: 1.608.2-61064218
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.3086

I usually have two instances of ubuntu 22.04 running, one using wsl1, the other wsl2.
After resuming from sleep wsl2 hangs, with vmmem process using all available CPU,
wsl shutdown or teminate hangs.
wsl1 instance is still ok, but have to reboot to get rid of vmmem process.

@2pl
Copy link

2pl commented Jul 9, 2023

seems to be a duplicate of #6982

@deragon
Copy link

deragon commented Nov 27, 2023

In my case, all the GUI applications running under WSLg die. However, the initial terminal from which they have been launch still runs. It might not be related with this issue and I should probably open a new issue.

Still, only a few weeks ago, GUI applications survived Sleep mode.

$ wsl.exe --version
WSL version: 2.0.9.0
Kernel version: 5.15.133.1-1
WSLg version: 1.0.59
MSRDC version: 1.2.4677
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.3693

@tietopetolo
Copy link

Can confirm same problem here. When the laptop goes to sleep wsl wont start again, this is especially annoying when docker and kubernetes build because you lose your work with building images that is stored in the WSLmem.

@SylvainTran
Copy link

I have the same issue on Windows 10 pro with running wsl2. After waking the computer from sleep, wsl tends to not function properly (frozen inside terminal).

@Rconybea
Copy link

Rconybea commented Apr 2, 2024

I am experiencing this problem several times a day, when and only when PC sleeps.

  1. Windows owned by programs like chromium, xclock never reappear after wakeup.
  2. new X11 programs hang, never display a window.
  3. emacs window disappears, and a few minutes after wakeup emacs crashes with message.
Connection lost to X server ':0'
Fatal error 6: Aborted

X11 server gets restarted automatically once it's crashed; after that X11 programs seem to start normally.

I don't know if it's relevant, but chromium makes complaints about egl during startup like:

ERR: Display.cpp:1023 (initialize): ANGLE Display::initialize error 12289: glXQueryExtensionsString returned NULL

(although seems otherwise to work for my purposes)

WSL version 2.1.5.0
Kernel 5.15.146.1-2
WSLg version 1.0.60

@zecevicp
Copy link

zecevicp commented Aug 1, 2024

Same issue here with WSL 2.3.12.0

@eezstreet
Copy link

Still is happening, and a major issue.

If I start WSL and Docker is installed, then put the computer to sleep and bring it back up, the CPU usage will climb to 100% and stay stuck there. And I cannot terminate wsl as it seems to be frozen.

@wcruz-br
Copy link

More than 2 years after the first report, this problem is still there. If the computer is suspended or hibernates with WSL and Docker Desktop running, WSL hangs. I can't even execute a wsl --shutdown and a reboot is needed.

@jimklimov
Copy link

@wcruz-br : if it helps, you can try rudely killing vmmem.exe in Task Manager (Details tab for processes), if the proper wsl --shutdown is stuck for too long.

@wcruz-br
Copy link

wcruz-br commented Dec 5, 2024

I solved it uninstalling Docker for Windows. 🤷
Now I'm using "plain" Docker (CLI) and Portainer.

@QAnders
Copy link

QAnders commented Dec 6, 2024

I solved it uninstalling Docker for Windows. 🤷 Now I'm using "plain" Docker (CLI) and Portainer.

I didn't suffer from the crashes after a few WSL2 updates, but my Docker Desktop was often causing issues instead.
I installed Docker in WSL2 (Ubuntu) instead and it runs much better and uses much fewer resources now!
I can easily run 10 containers at a time, while with Docker Desktop the limit was three or four...

Unfortunately Portainer is not a free product so I do everything in CLI for Docker... 😅

@wcruz-br
Copy link

Unfortunately Portainer is not a free product so I do everything in CLI for Docker... 😅

You can use the community edition for free, installing it in a local container. That's what I do here. 😉

@jimklimov
Copy link

jimklimov commented Dec 12, 2024

My earlier comment stands corrected - today I could not kill vmmem.exe in Task Manager (Access Denied) nor in other tools.

Killing related wsl*.exe processes was successful, except for wslservice and wslrelay that implement Windows service(s), but did not help kill vmmem. Stopping and quitting Docker Desktop (after the fact that it noticed the "Distro" going AWOL) also did not help. FWIW, in my case the distro is used not only for docker, but also for occasional Linux development.

Needless to say, wsl --shutdown hangs indefinitely (not always the case, sometimes it just takes a few minutes to stop - but took more than 10min today and my patience timer expired). When I attempt to stop/restart the "WSL Service" (in services.msc), it also tries and aborts.

Googling around, I found #8529 referenced from https://superuser.com/questions/1645056/how-can-i-stop-vmmem-process with this gem for a force-kill:

taskkill /f /im wslservice.exe

...which worked for me and instantly killed the stragglers like vmmem.exe as well as the service implementation wsl*.exe processes.
Docker and WSL terminal do start afterwards, with "0 min" uptime in the Linux environment :)

Note that other posts in that SU discussion offer more processes to try killing, or services to recycle, depending on how the Docker Desktop VM is backed (e.g. Hyper-V) which may be in scope for those who come to research this problem but may be out of scope for WSL issue/ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests