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 + WSLg + systemd support Conflict #9257

Closed
1 of 2 tasks
klabacher opened this issue Dec 2, 2022 · 16 comments
Closed
1 of 2 tasks

WSL2 + WSLg + systemd support Conflict #9257

klabacher opened this issue Dec 2, 2022 · 16 comments

Comments

@klabacher
Copy link

klabacher commented Dec 2, 2022

Version

Microsoft Windows 11 [10.0.22621.900]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

Linux version 5.15.74.2-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220)

Distro Version

Kali

Other Software

x11-apps (7.7+9)
systemd 252 (252.1-1)
+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY -P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified
WSL: 1.0.1.0
kernel: 5.15.74.2
WSLg: 1.0.47
MSRDC: 1.2.3575
Direct3D: 1.606.4
DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp

Repro Steps

At windows terminal:

wsl --install KALI
sudo nano /etc/wsl.conf

[boot]
systemd=true

wsl --shutdown
wait for about 1 minute
wsl
apt-get install x11-apps
xcalc

Expected Behavior

After enabling systemd at .wslconfig. WSLg should behave well and as example xcalc

Actual Behavior

No window open and any log in console

Diagnostic Logs

If systemd support goes back to false, after restart(wsl --shutdown), wslg works 10/10

WslLogs-2022-12-02_14-44-50.zip
WSL logs

nvidia-smi logs --> NVIDIA-SMI 520.61.03 Driver Version: 522.06 CUDA Version: 11.8

|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0  On |                  N/A |
| 30%   39C    P8    10W / 100W |   2277MiB /  4096MiB |     14%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+```
@klabacher
Copy link
Author

Interop is not working in the same behaviour as wslg

# cmd.exe
run-detectors: unable to find an interpreter for /mnt/c/WINDOWS/system32/cmd.exe

@Morphlng
Copy link

Morphlng commented Dec 3, 2022

I've met the same problem with the latest update of WSL.

WSL info

WSL version: 1.0.0.0
Kernel version: 5.15.74.2
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22621.900

Usage

I'm using Cypress with WSLg, it works fine before 1.0.0 release. Today I've tried again, and it prompt me with the message the test runner unexpectedly exited via a exit event with signal SIGSEGV and at the very end a Segmentation Fault. I've completely removed the installation and reinstalled Cypress, then it came to me Missing X server or $DISPLAY.

Fix

I found this issue and tried to disable systemd support in my WSL. It works fine ever since!

So, it does seem like a bug in between WSLg and systemd. However, even with systemd enabled, I can still use some gui tools like gedit. I'm not sure what is causing a difference?

@klabacher
Copy link
Author

Sure, but this should not be a normal behaviour from wsl at all as in any documentation is said that wslg and systemd have conflicts.

Btw, the problem itself is at the systemd init scripts as it does not setup wsl tools as the original one. Basically its a poor integration

@klabacher
Copy link
Author

Found on wslg container's stderr.log file :

[11:51:03.103] <5>WSLGd: Run:104: pid 516 exited with status 1, /mnt/c/User/user/AppData/Local/Microsoft/WindowsApps/MicrosoftCorporationII.WindowsSubsystemForLinux_8wekyb3d8bbwe/msrdc.exe /v:5B8F794F-409A-4BE9-B9EB-CF45133CC00D /hvsocketserviceid:D029013C-FACB-11E6-BD58-64006A7986D3 /silent /wslg /plugin:WSLDVC_PACKAGE /wslgsharedmemorypath:WSL\5B8F794F-409A-4BE9-B9EB-CF45133CC00D\wslg C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.3.0_x64__8wekyb3d8bbwe\wslg.rdp 
[11:51:03.110] <3>WSLGd: LogException:74: Exception: No such file or directory @../ProcessMonitor.cpp:72 (LaunchProcess)

@klabacher
Copy link
Author

After 10 hours of pure debugging, found out that the problem was a comflict with binfmts WSLInterop file and mono detector.
As interop was not working, wslg could not spawn their process in windows.

Maybe a fix is to make wslg machine more independent from the changes on wsl user container

@hideyukn88
Copy link
Member

@Morphlng,

However, even with systemd enabled, I can still use some gui tools like gedit. I'm not sure what is causing a difference?

There is a issue that some systemd unit removes X socket under /tmp, this is why Wayland native application, such as gedit, keep working while X11 app does not work. We made a fix in WSL 1.0.3 for that, please try out when you have a chance, thanks!

@hideyukn88
Copy link
Member

After 10 hours of pure debugging, found out that the problem was a comflict with binfmts WSLInterop file and mono detector. As interop was not working, wslg could not spawn their process in windows.

Maybe a fix is to make wslg machine more independent from the changes on wsl user container

@0xdrop, thanks for analysis, but I'm not fully understand this, would you please describe a bit more details, thanks again for helping us!

@klabacher
Copy link
Author

Sure, a better written report here:

  1. X11 /tmp socket been overwritten from tmpfilecleaner systemd service. Upgrading to 1.0.3 solved this issue.
  2. Gui applications been launch but any screen been shown. Found at WSLg container internal stderr log file, that Wayland and PulseServer was launched normally, but RDPserver could not connect to socket with a not found file error.
  3. Interop failing with Error: unable to find interpreter for cmd.exe. Later found that the error was in binfmts
  4. WSL binfmts file was in conflict with a external package named mono, after deleting that conflicting file Interop became working properly.
  5. After fixing that conflict and doing a full restart all things went normally and stuff worked as they should

Ideas

Make a way that all WSL files as made in x11 /tmp socket cant be overwritten from external applications, make interop binfmts file to be priority . Bring a better report on how WSL internals work inside linux image.

thanks for the attention @hideyukn88 , in the case of more info or logs needed just type here again! ;)

@hideyukn88
Copy link
Member

@0xdrop, thanks for details, just for clarification, do you mean mono as https://www.mono-project.com/docs/getting-started/install/linux/ ?

@klabacher
Copy link
Author

Yes! Mono is present at some of the Kali metapackages, then its normal to a lot of users that use wsl plus this distro to have this same issue

@hideyukn88
Copy link
Member

@0xdrop, thank you very much, now I'm able to reproduce the issue locally, thanks!

@hideyukn88
Copy link
Member

@0xdrop, I noticed this issue is already closed and WSL 1.0.3 did address WSLg + systemd issue, do you mind opening new issue for WSLg + mono lost RDP connection? thanks!

@klabacher
Copy link
Author

Open at this repo or at wslg one?

@hideyukn88
Copy link
Member

@0xdrop, since launching Windows's exe from WSL is WSL feature (not WSLg), so please open here.

@benken-parasoft
Copy link

In case this helps anyone, I did this:

sudo apt remove mono-runtime
sudo apt autoremove

Now, wslg is working again with systemd enabled in my /etc/wsl.conf.
Previously, wslg seemed broken where windows would not open. My /mnt/wslg/stderr.log was growing indefinitely with a repeating error about "msrdc.exe exited" and "No such file or directory @../ProcessMonitor.cpp:72 (LaunchProcess)"

@hideyukn88
Copy link
Member

@0xdrop, thanks for helping us to diagnose the issue, and now this issue is fixed (or technically workarounded specifically for msrdc.exe) by microsoft/wslg#926, although Windows interoperability in general still remain broken.

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

4 participants