microsoft / wslg

Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios
MIT License
9.94k stars 299 forks source link

msrdc continously restarting #901

Open Kilill opened 1 year ago

Kilill commented 1 year ago

Windows build number:

10.0.19045.2311

Your Distribution version:

20.04

Your WSL versions:

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.19045.2311

Steps to reproduce:

  1. Upgraded windows to latest release
  2. wsl --update
  3. wsl

WSL logs:

stderr.log versions.txt weston.log wlog.log pulseaudio.log

WSL dumps:

No response

Expected behavior:

wsl should start and graphical linux progams should run

Actual behavior:

wsl start and shows command prompt and works as expected for a linux distro in text/terminal mode. but windows system is lagging, and almost all windows constantly repaiting. And ofc no graphicl linux progs works.

checking stderr.log i see this:

[10:51:31.376] <5>WSLGd: Run:104: pid 15 exited with status 9, /mnt/c/Users/kill/AppData/Local/Microsoft/WindowsApps/MicrosoftCorporationII.WindowsSubsystemForLinux_8wekyb3d8bbwe/msrdc.exe /v:82ACAEE4-02E2-4CE9-9812-B0592ABC85B8 /hvsocketserviceid:15489104-FACB-11E6-BD58-64006A7986D3 /silent /wslg /plugin:WSLDVC_PACKAGE /wslgsharedmemorypath:WSL\82ACAEE4-02E2-4CE9-9812-B0592ABC85B8\wslg C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\wslg.rdp 
Error: debug scope named 'rdp-audio' is already registered.
Error: debug scope named 'rdp-audio-in' is already registered.
olivier-med commented 1 year ago

Exactly the same issue since latest update around 10 days ago (wsl + wslg if I remember correctly).

Ton of errors in the Event Viewer, active window lost the focus every 10/15 sec and no more GPU detected inside distribution (Debian 11 and Ubuntu 22) - impossible to use and work with the PC.

Screenshot 2022-11-29 105458 Screenshot 2022-11-29 105440

After trying to downgrade/reinstall wsl/wslg/video drivers/distribution, the only way to get something working a bit is to disable GUI application support using the parameter guiApplications=false in .wslconfig.

We really need a quick fix, my whole team is unable to work in proper condition as we need GPU support inside our containers.

hideyukn88 commented 1 year ago

@Kilill, @olivier-med, thanks for reporting the issue. Would you please create below file under your Windows's user profile folder and see if it's fixed? it's .wslgconfig, not .wslconfig.

c:\Users\[Your Windows Username]\.wslgconfig

[system-distro-env]
WSLG_USE_MSTSC=true

Thanks!

Kilill commented 1 year ago

Doing that (and ofc removing the guiApplication=false line from wslconfig only results in the Remote Desktop Connection Usage page beeing popped on the screen with usage instructions, pressing the OK button will imidiatly pop it again. WSL does start and gives the normal text prompt. And ofc trying to start any graphical X program just hangs and must be terminated with ctrl-C. Only way to remove the usage page is to shutdown wsl first (`wsl --shutdown')

To me it seems that MSTC is given an incorrect parameter ?

olivier-med commented 1 year ago

Hello, did that this morning and same behaviors (without guiApp). As soon as a distribution is started following the wsl --shutdown, ton of errors in the EventViewer and the active window lost focus every few seconds.

hideyukn88 commented 1 year ago

@Kilill, @olivier-med, thanks so much for trying out, at this point I need the msrdc/mstsc data from Windows side, please report problem using Feedback Hub and please...

1: put link to this Github page at description.

2: select below category.

image

3: record the problem by selecting "recreate my problem" and "start recording", you can restart WSL at this point.

image

Thank you very much for helping us.

Kilill commented 1 year ago

Would love to, but there are no options as indicated for "atach" anything, much less a "recreate my problem" in the "Feedback Hub" app

hideyukn88 commented 1 year ago

@Kilill, once you start recording, it will automatically collect the data we need for diagnosis, and it will attach the data to the report once you finish recording, thanks!

Kilill commented 1 year ago

What in trying to say is that the Feedback ap does not have a recreate my problem button at all, so it is not possible to create a recording, attaching screenshots from the "Feedback Hub" session, nowhere do i get the options indicated above to "Start Recording" and ofc "Submit" justs submits the and returns

fb1 fb2 fb3 fb4 fb5
Masamune3210 commented 1 year ago

It's because you have optional diagnostic data disabled Screenshot_20221205-141349.jpg

Kilill commented 1 year ago

Well. That's to bad, to enable that it seems the hole "telemetry phone home to MS" has to be enabled, which is not going to happen.

olivier-med commented 1 year ago

Sorry won't be possible for me also, these rules are enforced by our company's policies.

hideyukn88 commented 1 year ago

@Kilill, @olivier-med, I understand that, so I come up with alternative way to collect the error log we need.

1: add .wslgconfig as described at https://github.com/microsoft/wslg/issues/901#issuecomment-1335757205. 2: save this mstsc.txt to local disk, and rename to mstsc.wprp. 3: start command prompt (cmd.exe) with admin privilege. 4: at same folder where mstsc.wprp is saved, run wpr -start mstsc.wprp!MSTSC.Verbose -filemode. 5: run wsl --shutdown to ensure WSL is terminated. 6: then restart WSL, and make sure msrdc.exe is contiguously restarting. 7: from same command prompt as step 4, run wpr -stop mstsc.etl. 8: then mstsc.etl should be created at same folder, and please share this file with us.

Thanks!

olivier-med commented 1 year ago

Hello, Thanks for the procedure, and here is the etl file (after about 1 minute and a lot of crash in the event viewer). mstsc.etl.zip

hideyukn88 commented 1 year ago

@olivier-med, thanks for sharing log, up to this point, I have assumed you and @Kilill could be seeing same issue, thus I used the weston.log from him as reference, but now I can't be sure, do you see which message, below a) or b) or none of them at your /mnt/wslg/weston.log? The numbers portion can be different but please look for bold text.

a) [10:51:44.860] unable to checkDescriptor for 0x55f753fd49a0

or

b) [17:04:49.490] CreateWndow(): rdp_peer is not initalized

@Kilill, would you please help us to share the log, it would be very appreciated.

Thanks!

Kilill commented 1 year ago

Tried that but as before having WSLG_USE_MSTSC=true in .wslgconfig pops the a usage page dialog for mstsc. Leads me to believe that there's an incorrect parameter/option in the call .

WSL does start in text only mode though

Not sure if it helps you any but ran the same procedure with removed WSLG_USE_MSTSC=true both files are in the zip, mstsc_1.etl is with WSLG_USE_MSTSC=true mstsc_2.etl is without mstsc.zip

Kilill commented 1 year ago

with WSLG_USE_MSTSC=true i get the CreateWndow(): rdp_peer is not initalized in weston.log which i guess is understandable since mstsc pops its usage page.

if it helps: i asume that the command string used is the one from stderr.log: /mnt/c/Windows/System32/mstsc.exe /v:77F0E562-DACC-434C-BC3E-D7EF37B02B1B /hvsocketserviceid:729EC02A-FACB-11E6-BD58-64006A7986D3 /silent /wslg /plugin:WSLDVC_PACKAGE /wslgsharedmemorypath:WSL\77F0E562-DACC-434C-BC3E-D7EF37B02B1B\wslg C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\wslg.rdp

running that from the wsl command line ofc pops the usage dialog. i fiddled around with that for a bit removing options and it seems my mstsc doesnt like any option stating with wslg ie /wslg and /wslgsharedmemorypath stops it from poping the usage page but instead complains about the rdp file missing...

btw seems a new version of wsl is available il update and see if it helps any

(5 min laters) nope no change

olivier-med commented 1 year ago

@hideyukn88 - "CreateWndow(): rdp_peer is not initalized" is the message I have.

If it can help, here are logs from /mnt/wslg/ folder stderr.log weston.log wlog.log pulseaudio.log

hideyukn88 commented 1 year ago

@Kilill, ah I see, you are on Windows 10, not 11, and you are right that mstsc.exe included in Windows 10 doesn't support those parameters and can't be used .wslgconfig, so please remove it. Instead, would you please add below registry key before running wpr.exe at above 4).

3.5: run reg add "HKCU\Software\Microsoft\Terminal Server Client\Default" /v EnableMSRDCAutoTracing /t REG_DWORD /d 1 /f on admin privileged cmd.exe.

and you can remove this registry key after step 7.

7.5: run reg delete "HKCU\Software\Microsoft\Terminal Server Client\Default" /v EnableMSRDCAutoTracing /f

then share the mstsc.etl with us. Very appreciated for your help!

Kilill commented 1 year ago

Here you go:

mstsc.zip

hideyukn88 commented 1 year ago

@olivier-med, thanks for sharing the log, and it shows it indeed your case and @Kilill's case is different.

In your case, the RDP connection to WSLg is not established at all, while @Kilill's case shows RDP connection is established but disconnected soon after.

Is your computer managed by your corporation by group policy? if so, would you please share output from reg QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /S on Windows's command prompt? Or do you install 3rd party software for RDP/Terminal Services? such as www.terminalworks.com? Or any 3rd party networking monitoring/firewall software? thanks!

olivier-med commented 1 year ago

Hello,

here is the command result:

D:\
λ reg QUERY "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services" /S

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services
    DisablePasswordSaving    REG_DWORD    0x1
    fDisableCcm    REG_DWORD    0x1
    fDisableCpm    REG_DWORD    0x1
    fForceClientLptDef    REG_DWORD    0x0
    fSingleSessionPerUser    REG_DWORD    0x1
    fDisableCam    REG_DWORD    0x1
    fDisableAudioCapture    REG_DWORD    0x1
    fEnableSmartCard    REG_DWORD    0x0
    fDisableLPT    REG_DWORD    0x1
    fDisablePNPRedir    REG_DWORD    0x1

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client
    fEnableUsbBlockDeviceBySetupClass    REG_DWORD    0x1
    fEnableUsbNoAckIsochWriteToDevice    REG_DWORD    0x50
    fEnableUsbSelectDeviceByInterface    REG_DWORD    0x1

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client\UsbBlockDeviceBySetupClasses
    1000    REG_SZ    {3376f4ce-ff8d-40a2-a80f-bb4359d1415c}

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services\Client\UsbSelectDeviceByInterfaces
    1000    REG_SZ    {6bdd1fc6-810f-11d0-bec7-08002be2092f}

I discussed a bit with IT, and as far as I know, there was no modifications in group policies, nor changes in software (anti virus or fw) for a long time.

byjrack commented 1 year ago

Same boat as OP. We use Citrix and yeah unless you disable WSLg the msrdc bit just crashes every couple seconds until all WSL processes are shutdown. Nothing jumping out in TS policy, but there are hooks in play that can cause issues I am sure.

And same boat on the MSTSC flag as it just does the usage help popup so no help there.

hideyukn88 commented 1 year ago

@byjrack, do you have a chance to try out without Citrix is installed? Does WSLg work fine? When msrdc.exe is running for WSLg connection, it indeed disables all 3rd party plugins to avoid any possible conflicts (as previously there is issues observed with 3rd party plugins, such as TSPrint). Would you please check which message is logged in weston.log at https://github.com/microsoft/wslg/issues/901#issuecomment-1343151633? thanks!

byjrack commented 1 year ago

Can't pull Citrix since that is what is brokering the desktop session and I need to figure out how to make WSL and Citrix coexist. For now it's disable WSLg, but that's a bit complicated to do from the center and ideally I would like to make WSL work out of box even if folks don't use WSLg as a feature.

weston

[12:29:55.587] app list entry updated: Key:ubuntu-desktop-installer_ubuntu-desktop-installer, Name:Install RELEASE (Ubuntu)
[12:29:55.783] CreateWndow(): rdp_peer is not initalized
[12:29:56.063] Spawned Xwayland server, pid 27
[12:29:56.563] xfixes version: 5.0
[12:29:56.596] created wm, root 912
[12:29:57.589] retry_find_icon_file: icon (ubiquity) retry count (1)
[12:29:57.589] find_icon_file: icon (ubiquity) search retry:(2) global:(1)
[12:29:59.591] retry_find_icon_file: icon (ubiquity) retry count (2)
[12:29:59.592] find_icon_file: icon (ubiquity) search retry:(3) global:(1)

stderr is basically this forever

[12:29:57.561] <5>WSLGd: Run:104: pid 17 exited with status 126, /mnt/c/Users/User/AppData/Local/Microsoft/WindowsApps/MicrosoftCorporationII.WindowsSubsystemForLinux_8wekyb3d8bbwe/msrdc.exe /v:11D7C9D0-E168-422E-BD23-BE31C8C10C95 /hvsocketserviceid:41AD4E99-FACB-11E6-BD58-64006A7986D3 /silent /wslg /plugin:WSLDVC_PACKAGE /wslgsharedmemorypath:WSL\11D7C9D0-E168-422E-BD23-BE31C8C10C95\wslg C:\Program Files\WindowsApps\MicrosoftCorporationII.WindowsSubsystemForLinux_1.0.0.0_x64__8wekyb3d8bbwe\wslg.rdp 
olivier-med commented 1 year ago

@hideyukn88 we also have on our desktop having the issues Citrix installed and it cannot be uninstalled as without it we are unable to do remote work :) But we don't have updates on Citrix since few months.

hideyukn88 commented 1 year ago

@byjrack @olivier-med, what exact Citrix software do you have in your local computer? thanks!

olivier-med commented 1 year ago

image

byjrack commented 1 year ago

My case is Citrix Desktop VDA version 7.32.0.6

The policy tends to try to control sideways access via RDP because it can cause conflicts.

hideyukn88 commented 1 year ago

@byjrack @olivier-med, thanks, we will internally reach out to Citrix to figure out further, thanks!

hideyukn88 commented 1 year ago

@Kilill, would you please share the RdClientAutoTrace file under %TEMP%\DiagOutputDir? Please see timestamps and pick one or two files close to when WSL is launched, thanks!

byjrack commented 1 year ago

If it helps. I did set the regkey as well and no autotrace files are being generated. Even did a reboot in between just in case though i get it looks like a CU key that will be read on launch. Again expecting Citrix is preventing RDC from starting as expected.

mstsc.zip

Kilill commented 1 year ago

Only one file present:

RdClientAutoTrace.zip

hideyukn88 commented 1 year ago

Only one file present:

@Kilill, thanks for sharing it, unfortunately this doesn't contain the information I'm looking for, but currently we have in-house reproduce of the issue which exhibit same pattern observed at the log you previously shared, and we are working on the fix, and will update here once the fix ready to release, thanks for helping us!

mmorley0395 commented 1 year ago

i have the same issue, and the issue seems to only be when Citrix is open. my solution was simply to uninstall the wsl version from the microsoft store. i still have the other WSL version installed that predates the microsoft store version.

probably not a fix for people who need the latest and greatest but for now it fixed the flickering and made my citrix usable again while WSL is open.

byjrack commented 1 year ago

The 2365/Dec22 cumulative opened the floodgates on the Store version though so I am just having folks disable WSLg via .wslconfig as I can't hold back the kernel updates for very long.

hideyukn88 commented 1 year ago

@mmorley0395, thanks for info. Would you please clarify what do you mean by "Citrix is open"? This seems imply having Citrix open software installed itself doesn't cause problem, but when it's running? Also, please share with us what Citrix software you have and its version? thanks for your help!

mmorley0395 commented 1 year ago

@hideyukn88 apologies, I just mean when I am using a Citrix Workspace (remote desktop), the issue occurs, whereas when I am physically in the office logged into my machine, I have no problems. I'm using Citrix Workspace Version: 22.11.0.12 (2211). Let me know if you need additional info/clarification; but I'm a pretty new WSL user so might require some hand holding to give detailed outputs / log files!

hideyukn88 commented 1 year ago

@mmorley0395, would you please share the log file mentioned at https://github.com/microsoft/wslg/issues/901#issuecomment-1353837133 ? thanks!

mmorley0395 commented 1 year ago

etls.zip sure- these three are close to when WSL was launched.

pearj commented 1 year ago

Hi @hideyukn88,

I am also having the same issue and I'm using WSL 2 on Windows 10 inside a Citrix Session.

WSL version: 1.0.3.0
Kernel version: 5.15.79.1
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.19045.2364

I am running the Citrix Virtual Apps and Desktops 7 1912 LTSR CU1 - Virtual Delivery Agent version: 1912.0.1000.24525

Potentially I might be able to upgrade the Citrix client to 7 1912 LTSR CU6, but probably nothing more modern than that.

I followed your instructions for that wpr capture, and have uploaded it, although I don't know if there is anything exciting in there. mstsc-etl.zip

mobra66 commented 1 year ago

I can confirm the same issues using Citrix Workspace 22.10.6.1, after starting WSL2/WSLg. In my case, I found this workaround: If I disconnect the Citrix session, leaving WSL2/WSLg started, and then just reconnect, the problem seems to disappear (only for that session though, it is not a permanent fix).

$ wsl.exe --version
WSL-version: 1.0.3.0
Kerneversion: 5.15.79.1
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: 10.0.19044.2364
pearj commented 1 year ago

I wonder if disabling Citrix hooks for the crashing process might help the problem?

I remember seeing this issue with npcap: https://github.com/nmap/npcap/issues/226#issuecomment-801445374

hideyukn88 commented 1 year ago

@pearj, thanks for info, have you tried the registry key settings mentioned at https://support.citrix.com/article/CTX107825/how-to-disable-citrix-api-hooks-on-a-perapplication-basis ? thanks!

pearj commented 1 year ago

@hideyukn88 So I tried this registry file:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\CtxHook]
"ExcludedImageNames"="msrdc.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Citrix\CtxHook]
"ExcludedImageNames"="msrdc.exe"

[HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Citrix\CtxHook64]
"ExcludedImageNames"="msrdc.exe"

It stopped the continual crashing, but it seems that WSLg wasn't usable yet. I tried xeyes and nothing appeared:

stderr.log

[13:13:06.708] <5>WSLGd: FontFolder:14: FontMonitor: start monitoring /mnt/wslg/distro/usr/share/fonts
[13:13:06.709] <5>WSLGd: FontMonitorThread:228: FontMonitor: monitoring thread started.
[13:13:06.710] <5>WSLGd: DumpMonitorFolders:125: FontMonitor: monitoring /mnt/wslg/distro/usr/share/fonts, and it is *not* added to X11 font path
dbus[17]: Unknown username "systemd-oom" in message bus configuration file
dbus[17]: Unknown username "pulse" in message bus configuration file
could not load cursor 'grabbing'
could not load cursor 'dnd-move'
could not load cursor 'dnd-copy'
glamor: 'wl_drm' not supported
Missing Wayland requirements for glamor GBM backend
Failed to initialize glamor, falling back to sw
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Internal error:   Could not resolve keysym XF86FullScreen
Errors from xkbcomp are not fatal to the X server

Bottom of weston.log

[13:13:06.797] CreateWndow(): rdp_peer is not initalized
[13:13:06.900] Spawned Xwayland server, pid 24
[13:13:07.577] xfixes version: 5.0
[13:13:07.603] created wm, root 912
[13:13:08.666] unable to checkDescriptor for 0x55e3708ba4c0
[13:14:28.362] CreateWndow(): rdp_peer is not initalized
[13:15:17.961] CreateWndow(): rdp_peer is not initalized
[13:15:18.004] app_list_monitor_thread: loadIconEvent is signalled. XEyes
[13:15:18.004] app_list_monitor_thread: entry (nil), image (nil)
[13:15:18.004] set_window_icon(): rdp_peer is not initalized

I wonder if more citrix registry entries are required? I'm about to try HKLM\SYSTEM\CurrentControlSet\services\CtxUvi adding msrdc.exe; to the end of UviProcessExcludes. But I have to reboot to try

I tried to go through the npcap commit history to figure out what the fix for citrix was, but I couldn't find a super obvious commit message.

pearj commented 1 year ago

Ok so restarting did fix it, when opened wsl for the first time some warning came up related to connecting to something untrusted, I presume it meant wslg. Once I accepted that it started working!

UviProcessExcludes had a bunch of other, presumably default, executables listed in the registry property, so I had to modify it by hand, instead of via a registry entry.

I wonder what the process is for fixing wslg so that these exclusions are not necessary?

byjrack commented 1 year ago

I also had a case opened (81630401) with Citrix to start their triage. Why msrdc is nuking in this case vs working when connecting to another external RDP endpoint is a head scratcher. It's good to know that it seems to be related to the process hooks. Hopefully some additional cdftrace data will highlight the cause. I have to assume the issue is wsldvcplugin related given rdpcli functions fine in the vdi session for standard ops.

hideyukn88 commented 1 year ago

@pearj, thanks for trying out! Regarding to the connection confirmation dialog, is it same as https://github.com/microsoft/wslg/issues/841? thanks!

pearj commented 1 year ago

@hideyukn88 yes the confirmation dialog is #841 and I am running AuthenticationLevel 0x2, good to know a fix in the works for that.

abaebae commented 1 year ago

I got the same issue, thanks for the workaround. Are there any news on a proper fix?

I can confirm the same issues using Citrix Workspace 22.10.6.1, after starting WSL2/WSLg. In my case, I found this workaround: If I disconnect the Citrix session, leaving WSL2/WSLg started, and then just reconnect, the problem seems to disappear (only for that session though, it is not a permanent fix).

$ wsl.exe --version
WSL-version: 1.0.3.0
Kerneversion: 5.15.79.1
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: 10.0.19044.2364
Koki007365 commented 1 year ago

This issue is being caused by "Unicode Injection IME hook" that is "CxInjIme.dll". Once we added this hook "Unicode Injection IME hook" that is "CxInjIme.dll" to exclusion list we cannot see the msrdc crashes anymore with that WSL2/WSLg is just working fine.

  1. Backup the registry key Computer\HKEY_LOCAL_MACHIN E\SOFTWARE\Citrix\CtxHook\AppInit_Dlls\Unicode Injection IME hook
  2. Backup the registry key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Citrix\CtxHook\AppInit_Dlls\Unicode Injection IME hook
  3. Inside both the registry locations referenced above you will find a DWORD value called "flag"
  4. Set the data for this value to 0
  5. Reboot the VDA