WSL sometimes crashes when computer wakes from sleep
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 33.7k
- Forks
- 1.8k
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 116
Description
### Version
Microsoft Windows [Version 10.0.19044.2364]
### WSL Version
- [X] WSL 2
- [ ] WSL 1
### Kernel Version
5.15.79.1-microsoft-standard-WSL2
### Distro Version
Arch Linux
### Other Software
_No response_
### Repro Steps
1. Open a terminal to the Linux instance
2. Close laptop lid to put the computer to sleep
3. Wait till the next day (or more precisely, as far as I can tell, until the computer has gone from sleep to hibernation)
4. Start the computer again
5. Find that the Linux instance has died.
### Expected Behavior
I expect the Linux instance to also resume from sleep/hibernation without errors.
### Actual Behavior
The Linux shell is unresponsive, and in the Windows Terminal, I see the following message:
```
[process exited with code 1 (0x00000001)]
```
I do not think this is a duplicate of #9301, because the Linux instance can easily be started again without rebooting the computer.
I have run the `collect-wsl-logs.ps1` script and attached its output files as instructed ([WslLogs-2023-01-30_16-39-46.zip](https://github.com/microsoft/WSL/files/10544247/WslLogs-2023-01-30_16-39-46.zip)), but its console output indicates that it wasn't entirely successful:
```
PS C:\Users\[username]> .\collect-wsl-logs.ps1
Directory: C:\Users\[username]
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 30/01/2023 16:39 WslLogs-2023-01-30_16-39-46
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
The operation completed successfully.
Log collection is running. Please reproduce the problem and press any key to save the logs.
Saving logs...
There are no trace profiles running.
Error code: 0xc5583000
Logs saved in: C:\Users\[username]\WslLogs-2023-01-30_16-39-46.zip. Please attach that file to the GitHub issue.
```
The part starting with "Saving logs..." is of course from after the computer has woken again. And I have run that script successfully before, so I guess that the error is related to WSL crashing.
I have also checked Event Viewer and found some log entries there which seem like they could be relevant. In chronological order:
* When I first put the computer in sleep mode:
* Info: `The driver \Driver\vpcivsp for device ROOT\VPCIVSP\0000 stopped the power transition.`
* Info: `The system is entering sleep. Sleep Reason: Button or Lid`
* When it later resumes to switch to hibernation:
* Info: `The driver \Driver\vpcivsp for device ROOT\VPCIVSP\0000 stopped the power transition.`
* Error: `The ms-resource:AppName service terminated unexpectedly. It has done this 2 time(s).`
* Info: `The system is entering sleep. Sleep Reason: Hibernate from Sleep - Fixed Timeout`
The Error message there caught my eye. In Services, I can see that _ms-resource:AppName_ is actually `C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__8wekyb3d8bbwe\wslservice.exe`. So I guess this means that the WSL service crashes.
### Diagnostic Logs
_No response_
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the attached WSL logs and the Event Viewer entries around sleep, hibernation, and the wslservice.exe failure. Reproduce the WSL 2 crash across sleep-to-hibernation and compare the collected diagnostics; done means identifying and fixing the cause or documenting a confirmed limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100