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

Windows programs hang when started from WSL2 #7371

Closed
1 of 2 tasks
0anton opened this issue Aug 30, 2021 · 18 comments
Closed
1 of 2 tasks

Windows programs hang when started from WSL2 #7371

0anton opened this issue Aug 30, 2021 · 18 comments
Assignees

Comments

@0anton
Copy link

0anton commented Aug 30, 2021

Windows Build Number

Microsoft Windows [Version 10.0.19042.1165]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

4.19.128

Distro Version

Ubuntu 20.04

Other Software

No response

Repro Steps

Start any Windows executable, for example wsl.exe:

$ wsl.exe
<freeze>

Expected Behavior

Windows executable starts normally or fails with expected error message.

Actual Behavior

Program freezes. Impossible to interrupt with Ctrl-C. Only kill -9 can stop the process.

Diagnostic Logs

WSL2 integration with Windows, which allows execution of Windows programs [1], stops working.

Every new executable (wsl.exe in this example) remains blocked:

$ ps ax | grep /tools/init
 1109 pts/0    S+     0:00 /tools/init /mnt/c/WINDOWS/system32/cmd.exe /c autohotkey.bat
 2148 pts/1    S+     0:00 /tools/init /mnt/c/WINDOWS/system32/wsl.exe
 2319 pts/2    S+     0:00 /tools/init /mnt/c/WINDOWS/system32/wsl.exe
 2633 pts/3    S+     0:00 grep --color=auto /tools/ini

Typical state - process waits in accept4(..)

d057039:~$ strace -p 1109
strace: Process 1109 attached
accept4(4,

File descriptor 4 is s AF_VSOCK, a socket for host-vm communication. All processes looks the same:

d057039:~$ sudo lsof -p 1109
COMMAND  PID    USER   FD   TYPE             DEVICE SIZE/OFF             NODE NAME
cmd.exe 1109 d057039  cwd    DIR               0,42     4096 1407374884823550 /mnt/c/WINDOWS/system32
cmd.exe 1109 d057039  rtd    DIR               8,16     4096                2 /
cmd.exe 1109 d057039  txt    REG               0,18   632048  844424931918031 /tools/init
cmd.exe 1109 d057039    0u   CHR              136,0      0t0                3 /dev/pts/0
cmd.exe 1109 d057039    1u   CHR              136,0      0t0                3 /dev/pts/0
cmd.exe 1109 d057039    2u   CHR              136,0      0t0                3 /dev/pts/0
cmd.exe 1109 d057039    3u   CHR              136,0      0t0                3 /dev/pts/0
cmd.exe 1109 d057039    4u  sock                0,8      0t0            23751 protocol: AF_VSOCK
cmd.exe 1109 d057039    5u  unix 0x000000009215753c      0t0            23752 type=SEQPACKET

Blocked process can only be killed with kill -9

Other observations

  1. Interestingly, if the process is started with root privileges, all works as expected - processes starts, responds etc.

  2. If WSL2 is shutdown (wsl.exe --shutdown), execution of Windows programs starts working for a while, but ends soon with the same.

  3. Rebooting the systems helps only temporary. After a while blocking reappear again.

  4. Where is no difference in behavior, if I use Windows Terminal or wsl.exe as my console. Windows programs freeze in both.

  5. Both Windows console apps and GUI programs hang.

Logs

Refs

  1. https://docs.microsoft.com/en-us/windows/wsl/interop#disable-interoperability
@0anton 0anton changed the title Windows programs hangs when started from WSL2 Windows programs hang when started from WSL2 Aug 31, 2021
@benhillis
Copy link
Member

/logs

@ghost
Copy link

ghost commented Aug 31, 2021

Hello! Could you please provide more logs to help us better diagnose your issue? You can find instructions on how to attach logs here, please make sure to post the link to the Feedback Hub item in this chat so we can see it.

Thank you!

@0anton
Copy link
Author

0anton commented Aug 31, 2021

I updated linux kernel to 5.10.16.3-microsoft-standard-WSL2 and Windows to 10.0.19043.1165. Freezing still happens.

@ghost ghost removed the needs-author-feedback label Aug 31, 2021
@0anton
Copy link
Author

0anton commented Aug 31, 2021

Link to the feedback form: https://aka.ms/AAdosri

@0anton
Copy link
Author

0anton commented Aug 31, 2021

Logs manually collected: wsl.zip

@benhillis benhillis self-assigned this Sep 7, 2021
@0anton
Copy link
Author

0anton commented Sep 15, 2021

any need for more logs / tests?

@0anton
Copy link
Author

0anton commented Sep 15, 2021

Observations:

  1. When windows processes start hanging, no other windows process can be startet. Even wsl.exe from WSL2 environment will hang.
  2. Windows User Logout / Login helps to restore the possibility to launch Windows executables from WSL2 env.

@mands
Copy link

mands commented Dec 3, 2021

Have the same / similar issue myself - am using npiperelay.exe to bridge access from Linux -> Windows for ssh agent. At some point into a session, running npiperelay.exe from within WSL2 will just hang, where as previously you could run it and get the default help output. Running the binary from the Windows side works as expected.

I can see the process, but it's just blocked,

$ ps -aux | grep -i 'npipe'
mands    145  0.0  0.0   1704     4 pts/0    S+   16:40   0:00 /tools/init /home/mands/winhome/.wsl/npiperelay.exe --help
mands    258  0.0  0.0   6396  2300 pts/1    S+   16:41   0:00 grep --color=auto -i npipe

Restarting WSL doesn't seem to fix the issue, however fully rebooting does resolve it temporarily. I'm running Windows 11 and using WSL installed via the MS Store.

@zed76r
Copy link

zed76r commented Dec 22, 2021

Have the same / similar issue myself - am using npiperelay.exe to bridge access from Linux -> Windows for ssh agent. At some point into a session, running npiperelay.exe from within WSL2 will just hang, where as previously you could run it and get the default help output. Running the binary from the Windows side works as expected.

I can see the process, but it's just blocked,

$ ps -aux | grep -i 'npipe'
mands    145  0.0  0.0   1704     4 pts/0    S+   16:40   0:00 /tools/init /home/mands/winhome/.wsl/npiperelay.exe --help
mands    258  0.0  0.0   6396  2300 pts/1    S+   16:41   0:00 grep --color=auto -i npipe

Restarting WSL doesn't seem to fix the issue, however fully rebooting does resolve it temporarily. I'm running Windows 11 and using WSL installed via the MS Store.

I have the same issue too. If I can't open explorer.exe or other win32 programs on wsl2, I will hang on open WSL folder in windows at the same time.

@AaronFriel
Copy link

AaronFriel commented Jan 11, 2022

Same issue on Windows 11 22000.376, happens once per day.

Restarting WslService in Windows seems to resolve it. Any hanging processes will be killed, but after that I can cmd.exe from WSL fine.

I wonder if a common feature of @ZedG2, @mands, & @0anton is that we're all running WSL distributed through the store instead of Windows. If you open up services.msc and examine the Windows Subsystem for Linux Preview service, is the path a Store path like this?

C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.50.2.0_x64__8wekyb3d8bbwe\wslservice.exe

@RomanDanyk
Copy link

I have the same issue, and as @AaronFriel said, I also have WSL installed from Microsoft Store.

@0anton
Copy link
Author

0anton commented Jan 15, 2022

Yes, I've installed WSL2 from Windows Store too. However I neither have Windows Subsystem for Linux nor WslService in my Services list.

@RomanDanyk
Copy link

I do have the WslService in my system. However, its restarting doesn't help to fix the issue 😞

@zed76r
Copy link

zed76r commented Jan 26, 2022

How long it will take to fix? It's so annoying. I need to restart my PC several times EVERY SINGLE DAY!

@compulim
Copy link

compulim commented Mar 3, 2022

@AaronFriel confirm mine is installed from Windows Store and running wslservice.exe from C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemforLinux_0.51.3.0_x64__8wekyb3d8bbwe.

It usually happens after my laptop went to sleep.

WSL version: 0.51.3.0
Kernel version: 5.10.93.2
WSLg version: 1.0.30
Windows version: 10.0.22567.1

However, it doesn't work by restarting the WSL service.

wsl --shutdown
sc stop WslService
sc start WslService

Followed by starting Ubuntu, then run cmd.exe inside. It will hang again.

Will be great if anyone got a workaround other than rebooting.

@leoleoasd
Copy link

Any update on this?

@ktetzlaff
Copy link

ktetzlaff commented Apr 11, 2022

Looks like this is a duplicate of #7883 which has just been solved.

@OneBlue
Copy link
Collaborator

OneBlue commented Apr 12, 2022

Closing since this is a duplicate of #7883

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

10 participants