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

MSTSC crashes when resolution is changed by maximizing on a different monitor #1928

Closed
okhowang opened this issue Jun 23, 2021 · 43 comments · Fixed by #2175 or #2291
Closed

MSTSC crashes when resolution is changed by maximizing on a different monitor #1928

okhowang opened this issue Jun 23, 2021 · 43 comments · Fixed by #2175 or #2291

Comments

@okhowang
Copy link
Contributor

I have two monitors with 2560x1440 and 1920x1080 resolution.

and setting mstsc to use one monitor for full screen mode.

when I drag mstsc from a monitor to another, error occurred as below.
image
It means internal error.

and will got log


==> /home/.xorgxrdp.12.log <==
[1135171.145] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 2560 cy 1440
[1135171.145] rdpClientConProcessMsgVersion: version 0 0 0 1
[1135171.145] rdpClientConProcessScreenSizeMsg: set width 2560 height 1440 bpp 32
[1135171.146] rdpClientConProcessScreenSizeMsg: shmemid 254443553 shmemptr 0x7f5f87b3a000
[1135171.146] rdpRRScreenSetSize: width 2560 height 1440 mmWidth 677 mmHeight 381
[1135171.151] rdpRRGetInfo:
[1135171.151]   screen resized to 2560x1440
[1135171.157] rdpClientConProcessScreenSizeMsg: RRScreenSizeSet ok=[1]
[1135171.157] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 2560 cy 1440
[1135171.157] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 2560 cy 1440
[1135171.158] rdpClientConProcessMsgVersion: version 0 0 0 1
[1135171.158] rdpClientConProcessScreenSizeMsg: set width 2560 height 1440 bpp 32
[1135171.158] rdpClientConProcessScreenSizeMsg: shmemid 254476321 shmemptr 0x7f5f87b3a000
[1135171.158] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 2560 cy 1440
[1135171.158] rdpClientConProcessMsgClientInfo:
[1135171.158]   got client info bytes 7064
[1135171.158]   jpeg support 0
[1135171.158]   offscreen support 1
[1135171.158]   offscreen size 10485760
[1135171.158]   offscreen entries 100
[1135171.158] rdpClientConProcessMsgClientInfo: got RFX capture
[1135171.158]   cap_width 2560 cap_height 1472
[1135171.158] rdpClientConProcessMsgClientInfo: shmemid 254509089 shmemptr 0x7f5f87aea000 bytes 15073280
[1135171.158]   client can not do offscreen to offscreen blits
[1135171.158]   client can do new(color) cursor
[1135171.158]   client can not do multimon
[1135171.158] rdpRRSetRdpOutputs: numCrtcs 1 numOutputs 1 monitorCount 0
[1135171.158] rdpRRSetRdpOutputs: update output 0 left 0 top 0 width 2560 height 1440
[1135171.158] rdpRRUpdateOutput:
[1135171.159] rdpLoadLayout: keylayout 0x00000804 variant  display 12
[1135171.159] rdpkeybChangeKeyboardControl:
[1135171.159] rdpkeybChangeKeyboardControl: autoRepeat on
[1135171.159] rdpkeybChangeKeyboardControl:
[1135171.160] rdpkeybChangeKeyboardControl: autoRepeat on
[1135171.160] rdpClientConProcessMsgClientInfo:
[1135171.160]   got client info bytes 7064
[1135171.160]   jpeg support 0
[1135171.160]   offscreen support 1
[1135171.160]   offscreen size 10485760
[1135171.160]   offscreen entries 100
[1135171.160] rdpClientConProcessMsgClientInfo: got RFX capture
[1135171.160]   cap_width 2560 cap_height 1472
[1135171.160] rdpClientConProcessMsgClientInfo: shmemid 254541857 shmemptr 0x7f5f87aea000 bytes 15073280
[1135171.160]   client can not do offscreen to offscreen blits
[1135171.161]   client can do new(color) cursor
[1135171.161]   client can not do multimon
[1135171.161] rdpRRSetRdpOutputs: numCrtcs 1 numOutputs 1 monitorCount 0
[1135171.161] rdpRRSetRdpOutputs: update output 0 left 0 top 0 width 2560 height 1440
[1135171.161] rdpRRUpdateOutput:
[1135171.161] rdpLoadLayout: keylayout 0x00000804 variant  display 12
[1135171.161] rdpkeybChangeKeyboardControl:
[1135171.161] rdpkeybChangeKeyboardControl: autoRepeat on
[1135171.161] rdpkeybChangeKeyboardControl:
[1135171.161] rdpkeybChangeKeyboardControl: autoRepeat on
[1135171.240] rdpRRGetInfo:
[1135171.259] rdpInDeferredRepeatCallback:
[1135171.259] rdpkeybChangeKeyboardControl:
[1135171.259] rdpkeybChangeKeyboardControl: autoRepeat off
[1135171.260] rdpRRGetInfo:
[1135171.260] rdpInDeferredRepeatCallback:
[1135171.260] rdpkeybChangeKeyboardControl:
[1135171.260] rdpkeybChangeKeyboardControl: autoRepeat off
[1135171.268] rdpInDeferredRepeatCallback:
[1135171.268] rdpkeybChangeKeyboardControl:
[1135171.268] rdpkeybChangeKeyboardControl: autoRepeat off
[1135171.268] rdpInDeferredRepeatCallback:
[1135171.268] rdpkeybChangeKeyboardControl:
[1135171.268] rdpkeybChangeKeyboardControl: autoRepeat off
[1135171.273] rdpRRGetInfo:

==> /var/log/xrdp.log <==
[20210623-15:44:38] [INFO ] xrdp_caps_process_pointer: client supports new(color) cursor
[20210623-15:44:38] [INFO ] xrdp_process_offscreen_bmpcache: support level 1 cache size 10485760 MB cache entries 100
[20210623-15:44:38] [INFO ] xrdp_caps_process_codecs: nscodec, codec id 1, properties len 3
[20210623-15:44:38] [WARN ] xrdp_caps_process_codecs: unknown codec id 5
[20210623-15:44:38] [INFO ] xrdp_caps_process_codecs: RemoteFX, codec id 3, properties len 49

==> /home/.xorgxrdp.12.log <==
[1135171.458] KbdSync: toggling num lock
[1135171.458] rdpkeybChangeKeyboardControl:
[1135171.458] rdpkeybChangeKeyboardControl: autoRepeat off
[1135171.458] rdpkeybChangeKeyboardControl:
[1135171.458] rdpkeybChangeKeyboardControl: autoRepeat off
[1135171.486] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 2559 cy 1439

==> /var/log/xrdp.log <==
[20210623-15:44:38] [ERROR] SSL_read: I/O error
[20210623-15:44:38] [ERROR] xrdp_iso_send: trans_write_copy_s failed
[20210623-15:44:38] [ERROR] SSL_shutdown: I/O error
[20210623-15:44:38] [ERROR] Sending [ITU T.125] DisconnectProviderUltimatum failed

==> /home/.xorgxrdp.12.log <==
[1135171.521] rdpClientConRecv: g_sck_recv failed(returned -1)
[1135171.521] rdpClientConRecvMsg: error
[1135171.521] rdpClientConCheck: rdpClientConGotData failed
[1135171.525] rdpClientConDisconnect:
[1135171.525] rdpRemoveClientConFromDev: removing clientCon 0x55644bb73110
@matt335672
Copy link
Member

These errors from xrdp mean the other client has gone away unexpectedly:-

[20210623-15:44:38] [ERROR] SSL_read: I/O error
[20210623-15:44:38] [ERROR] xrdp_iso_send: trans_write_copy_s failed
[20210623-15:44:38] [ERROR] SSL_shutdown: I/O error
[20210623-15:44:38] [ERROR] Sending [ITU T.125] DisconnectProviderUltimatum failed

So something is happening which is upsetting mstsc.exe, but it's not clear what.

I've got a twin-screen Windows 10 VM set up as you have above, and I'm unable to reproduce your crash. Windows version here is 21H1 (OS build 19043.1052), and I'm using a development build of xrdp.

What platforms are you using? Are you using a .ini file to start the connection?

@okhowang
Copy link
Contributor Author

my windows version 21H1 19043.1023.
and I use mstsc without .ini file.

I've got a twin-screen Windows 10 VM set up as you have above, and I'm unable to reproduce your crash.

are your twin-screen have different resolution?
and are your start mstsc with fullscreen?
image

I will try other rdp client later

@matt335672
Copy link
Member

Yes - that's what I've got. My dialog looks like yours, but in English rather than Chinese. Since it's a VM I've set my screen resolutions to match yours.

A couple of other questions for you:-

  • What version of xrdp are you connecting to? I can rebuild that end and try again.
  • Do you have another Windows machine you can connect to from mstsc.exe ?

@okhowang
Copy link
Contributor Author

What version of xrdp are you connecting to? I can rebuild that end and try again.

xrdp version 0.9.15

Do you have another Windows machine you can connect to from mstsc.exe ?

I try another windows machine (21H1 19043.1055) mstsc.exe. and there was no internal error.

my windows version 21H1 19043.1023.

it is a client-side bug. I will try to upgrade this machine and try again.

@okhowang
Copy link
Contributor Author

I will try to upgrade this machine and try again.

crash remained after upgrading system version.

I compare two machine's mstsc, and found that options determine crashing or not.
image
if select LAN, it will be crash.
if select auto detected, it will be ok.

@metalefty
Copy link
Member

Can you also confirm with 16bpp color * "LAN", "Auto detect"?

@okhowang
Copy link
Contributor Author

Can you also confirm with 16bpp color * "LAN", "Auto detect"?

16bpp is ok for LAN and Auto detect, no internal error

@matt335672
Copy link
Member

I've reproduced this by using a LAN setting and 24bpp colour.

The debug logs are required to get some idea of what's going on. Here's what I've got so far from xrdp:-

xrdp.log
[20211119-11:57:10] [DEBUG] [dynamic_monitor_data(xrdp_mm.c:1080)] dynamic_monitor_data: msg_type 2 msg_length 56
[20211119-11:57:10] [DEBUG] [dynamic_monitor_data(xrdp_mm.c:1092)]   MonitorLayoutSize 40 NumMonitor 1
[20211119-11:57:10] [DEBUG] [dynamic_monitor_data(xrdp_mm.c:1107)]     Flags 0x00000001 Left 0 Top 0 Width 1920 Height 1200 PhysicalWidth 637 PhysicalHeight 421 Orientation 0 DesktopScaleFactor 100 DeviceScaleFactor 100
[20211119-11:57:10] [DEBUG] [libxrdp_send_pointer(libxrdp.c:719)] sending cursor
[20211119-11:57:10] [DEBUG] [libxrdp_send_pointer(libxrdp.c:747)] libxrdp_send_pointer: fastpath
[20211119-11:57:10] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:785)] xrdp_rdp_send_fastpath: no_comp_len 3221, fragmentation 0
[20211119-11:57:10] [DEBUG] [xrdp_sec_send_fastpath(xrdp_sec.c:1921)] xrdp_sec_send_fastpath: no crypt
[20211119-11:57:10] [DEBUG] [libxrdp_send_pointer(libxrdp.c:719)] sending cursor
[20211119-11:57:10] [DEBUG] [libxrdp_send_pointer(libxrdp.c:747)] libxrdp_send_pointer: fastpath
[20211119-11:57:10] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:785)] xrdp_rdp_send_fastpath: no_comp_len 3221, fragmentation 0
[20211119-11:57:10] [DEBUG] [xrdp_sec_send_fastpath(xrdp_sec.c:1921)] xrdp_sec_send_fastpath: no crypt
[20211119-11:57:10] [DEBUG] [xrdp_painter_create(xrdp_painter.c:140)] xrdp_painter_create:
[20211119-11:57:10] [DEBUG] [xrdp_painter_begin_update(xrdp_painter.c:243)] xrdp_painter_begin_update:
[20211119-11:57:10] [DEBUG] [xrdp_orders_init(xrdp_orders.c:110)] xrdp_orders_init: fastpath
[20211119-11:57:10] [DEBUG] [wm_painter_set_target(xrdp_painter.c:193)] wm_painter_set_target:
[20211119-11:57:10] [DEBUG] [xrdp_painter_end_update(xrdp_painter.c:265)] xrdp_painter_end_update:
[20211119-11:57:10] [DEBUG] [xrdp_painter_delete(xrdp_painter.c:171)] xrdp_painter_delete:
[20211119-11:57:10] [DEBUG] [send_server_monitor_resize(xup.c:1307)] send_server_monitor_resize: sent resize message with following properties to xorgxrdp backend width=1920, height=1200, bpp=24, return value=0
[20211119-11:57:10] [DEBUG] [send_server_monitor_full_invalidate(xup.c:1334)] send_server_monitor_full_invalidate: sent invalidate message with following properties to xorgxrdp backend width=1920, height=1200, return value=0
[20211119-11:57:10] [DEBUG] [xrdp_rdp_recv(xrdp_rdp.c:519)] xrdp_rdp_recv: out code 0 (skip data) data processed by channel id 1007
[20211119-11:57:10] [DEBUG] [lib_mod_process_orders(xup.c:1386)] lib_mod_process_orders: type 1
[20211119-11:57:11] [DEBUG] [xrdp_painter_create(xrdp_painter.c:140)] xrdp_painter_create:
[20211119-11:57:11] [DEBUG] [xrdp_painter_begin_update(xrdp_painter.c:243)] xrdp_painter_begin_update:
[20211119-11:57:11] [DEBUG] [xrdp_orders_init(xrdp_orders.c:110)] xrdp_orders_init: fastpath
[20211119-11:57:11] [DEBUG] [wm_painter_set_target(xrdp_painter.c:193)] wm_painter_set_target:
[20211119-11:57:11] [DEBUG] [lib_mod_process_orders(xup.c:1386)] lib_mod_process_orders: type 61
[20211119-11:57:11] [DEBUG] [server_paint_rects(xrdp_mm.c:3192)] server_paint_rects: 0x55ae03f16af0
[20211119-11:57:11] [DEBUG] [lib_mod_process_orders(xup.c:1386)] lib_mod_process_orders: type 2
[20211119-11:57:11] [DEBUG] [xrdp_painter_end_update(xrdp_painter.c:265)] xrdp_painter_end_update:
[20211119-11:57:11] [DEBUG] [process_enc_rfx(xrdp_encoder.c:329)] process_enc_rfx:
[20211119-11:57:11] [DEBUG] [process_enc_rfx(xrdp_encoder.c:330)] process_enc_rfx: num_crects 3 num_drects 1
[20211119-11:57:11] [DEBUG] [xrdp_painter_delete(xrdp_painter.c:171)] xrdp_painter_delete:
[20211119-11:57:11] [DEBUG] [process_enc_rfx(xrdp_encoder.c:393)] process_enc_rfx: rfxcodec_encode rv 0
[20211119-11:57:11] [DEBUG] [dynamic_monitor_data(xrdp_mm.c:1080)] dynamic_monitor_data: msg_type 2 msg_length 56
[20211119-11:57:11] [DEBUG] [dynamic_monitor_data(xrdp_mm.c:1092)]   MonitorLayoutSize 40 NumMonitor 1
[20211119-11:57:11] [DEBUG] [dynamic_monitor_data(xrdp_mm.c:1107)]     Flags 0x00000001 Left 0 Top 0 Width 1920 Height 1200 PhysicalWidth 637 PhysicalHeight 421 Orientation 0 DesktopScaleFactor 100 DeviceScaleFactor 100
[20211119-11:57:11] [DEBUG] [libxrdp_send_pointer(libxrdp.c:719)] sending cursor
[20211119-11:57:11] [DEBUG] [libxrdp_send_pointer(libxrdp.c:747)] libxrdp_send_pointer: fastpath
[20211119-11:57:11] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:785)] xrdp_rdp_send_fastpath: no_comp_len 3221, fragmentation 0
[20211119-11:57:11] [DEBUG] [xrdp_sec_send_fastpath(xrdp_sec.c:1921)] xrdp_sec_send_fastpath: no crypt
[20211119-11:57:11] [DEBUG] [libxrdp_send_pointer(libxrdp.c:719)] sending cursor
[20211119-11:57:11] [DEBUG] [libxrdp_send_pointer(libxrdp.c:747)] libxrdp_send_pointer: fastpath
[20211119-11:57:11] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:785)] xrdp_rdp_send_fastpath: no_comp_len 3221, fragmentation 0
[20211119-11:57:11] [DEBUG] [xrdp_sec_send_fastpath(xrdp_sec.c:1921)] xrdp_sec_send_fastpath: no crypt
[20211119-11:57:11] [DEBUG] [xrdp_painter_create(xrdp_painter.c:140)] xrdp_painter_create:
[20211119-11:57:11] [DEBUG] [xrdp_painter_begin_update(xrdp_painter.c:243)] xrdp_painter_begin_update:
[20211119-11:57:11] [DEBUG] [xrdp_orders_init(xrdp_orders.c:110)] xrdp_orders_init: fastpath
[20211119-11:57:11] [DEBUG] [wm_painter_set_target(xrdp_painter.c:193)] wm_painter_set_target:
[20211119-11:57:12] [DEBUG] [xrdp_painter_end_update(xrdp_painter.c:265)] xrdp_painter_end_update:
[20211119-11:57:12] [DEBUG] [xrdp_painter_delete(xrdp_painter.c:171)] xrdp_painter_delete:
[20211119-11:57:12] [DEBUG] [send_server_monitor_resize(xup.c:1307)] send_server_monitor_resize: sent resize message with following properties to xorgxrdp backend width=1920, height=1200, bpp=24, return value=0
[20211119-11:57:12] [DEBUG] [send_server_monitor_full_invalidate(xup.c:1334)] send_server_monitor_full_invalidate: sent invalidate message with following properties to xorgxrdp backend width=1920, height=1200, return value=0
[20211119-11:57:12] [DEBUG] [xrdp_rdp_recv(xrdp_rdp.c:519)] xrdp_rdp_recv: out code 0 (skip data) data processed by channel id 1007
[20211119-11:57:12] [DEBUG] [xrdp_mm_process_enc_done(xrdp_mm.c:2815)] xrdp_mm_process_enc_done: message back bytes 2914
[20211119-11:57:12] [DEBUG] [libxrdp_fastpath_send_frame_marker(libxrdp.c:1723)] libxrdp_fastpath_send_frame_marker:
[20211119-11:57:12] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:785)] xrdp_rdp_send_fastpath: no_comp_len 12, fragmentation 0
[20211119-11:57:12] [DEBUG] [xrdp_sec_send_fastpath(xrdp_sec.c:1921)] xrdp_sec_send_fastpath: no crypt
[20211119-11:57:12] [DEBUG] [libxrdp_fastpath_send_surface(libxrdp.c:1641)] libxrdp_fastpath_send_surface:
[20211119-11:57:12] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:785)] xrdp_rdp_send_fastpath: no_comp_len 2940, fragmentation 0
[20211119-11:57:12] [DEBUG] [compress_rdp_5(xrdp_mppc_enc.c:972)] Compression algorithim produced a compressed buffer which is larger than the uncompressed buffer. compression ratio 0.979646, flags 0x1
[20211119-11:57:12] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:810)] compress_rdp failed, sending uncompressed data. type 2, flags 1
[20211119-11:57:12] [DEBUG] [xrdp_sec_send_fastpath(xrdp_sec.c:1921)] xrdp_sec_send_fastpath: no crypt
[20211119-11:57:12] [DEBUG] [libxrdp_fastpath_send_frame_marker(libxrdp.c:1723)] libxrdp_fastpath_send_frame_marker:
[20211119-11:57:12] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:785)] xrdp_rdp_send_fastpath: no_comp_len 12, fragmentation 0
[20211119-11:57:12] [DEBUG] [xrdp_sec_send_fastpath(xrdp_sec.c:1921)] xrdp_sec_send_fastpath: no crypt
[20211119-11:57:12] [ERROR] [ssl_tls_log_error(ssl_calls.c:655)] SSL_write: I/O error
[20211119-11:57:12] [ERROR] [xrdp_sec_send_fastpath(xrdp_sec.c:1936)] xrdp_sec_send_fastpath: xrdp_fastpath_send failed
[20211119-11:57:12] [ERROR] [xrdp_rdp_send_fastpath(xrdp_rdp.c:834)] xrdp_rdp_send_fastpath: xrdp_sec_send_fastpath failed
[20211119-11:57:13] [ERROR] [libxrdp_fastpath_send_frame_marker(libxrdp.c:1749)] libxrdp_fastpath_send_frame_marker: xrdp_rdp_send_fastpath failed
[20211119-11:57:13] [DEBUG] [xrdp_mm_process_enc_done(xrdp_mm.c:2838)] xrdp_mm_process_enc_done: last set
[20211119-11:57:13] [DEBUG] [xrdp_mm_update_module_frame_ack(xrdp_mm.c:2785)] xrdp_mm_update_module_ack: frame_id_server 10
[20211119-11:57:13] [DEBUG] [lib_mod_process_orders(xup.c:1386)] lib_mod_process_orders: type 1
[20211119-11:57:13] [DEBUG] [xrdp_painter_create(xrdp_painter.c:140)] xrdp_painter_create:
[20211119-11:57:13] [DEBUG] [xrdp_painter_begin_update(xrdp_painter.c:243)] xrdp_painter_begin_update:
[20211119-11:57:13] [DEBUG] [xrdp_orders_init(xrdp_orders.c:110)] xrdp_orders_init: fastpath
[20211119-11:57:13] [DEBUG] [wm_painter_set_target(xrdp_painter.c:193)] wm_painter_set_target:
[20211119-11:57:13] [DEBUG] [lib_mod_process_orders(xup.c:1386)] lib_mod_process_orders: type 51
[20211119-11:57:13] [DEBUG] [libxrdp_send_pointer(libxrdp.c:719)] sending cursor
[20211119-11:57:13] [DEBUG] [libxrdp_send_pointer(libxrdp.c:747)] libxrdp_send_pointer: fastpath
[20211119-11:57:13] [DEBUG] [xrdp_rdp_send_fastpath(xrdp_rdp.c:785)] xrdp_rdp_send_fastpath: no_comp_len 4245, fragmentation 0
[20211119-11:57:13] [DEBUG] [xrdp_sec_send_fastpath(xrdp_sec.c:1921)] xrdp_sec_send_fastpath: no crypt
[20211119-11:57:13] [ERROR] [xrdp_sec_send_fastpath(xrdp_sec.c:1936)] xrdp_sec_send_fastpath: xrdp_fastpath_send failed

All I can say at the moment is something seems to be going wrong in xrdp_rdp_send_fastpath() following the resize. I've not been able to get any further yet.

@Nexarian
Copy link
Contributor

The code that is in XRDP currently for resize is a shadow of what I have now after working with Jay to get that enabled for the GFX branch. There are some fixes I have where I've refactored resizing into a state machine and also been much more aggressive about making sure that duplicate resizes don't happen, and blocked the bug that I describe below.

It looks like this is somewhat related to a bug where, on initial connection, an X * Y resize is also sent over the dynamic display channel even though it's not necessary. In the past XRDP has had many issues with a resize-to-a-resolution-you're-already-at message.

@matt335672 I'm happy to help debug this if you can elucidate some clear steps to reproduce. We could also jump on a Zoom call and look at it together.

@matt335672
Copy link
Member

Thanks @Nexarian - that's a great offer.

The crash doesn't happen when 'auto' is selected on the mstsc experience tab, so I need to work out exactly which option(s) is/are causing this to happen. I picked up on this late yesterday, so didn't have time for a lot of analysis. Also, when DEBUG logging is selected in development mode, things slow to a crawl.

After the weekend I'll do some analysis and post the info here. At the least I'm sure you'll want to check the GFX branch isn't affected.

@matt335672
Copy link
Member

No real progress on this this week. I've managed to cause a couple of crashes with xfreerdp but they don't seem to be related to this one!

The only way I can reproduce it currently is with a twin monitor setup on Windows. Monitors are different sizes. Procedure is as follows:-

  • Set LAN (10mbps or higher) on the experience tab
  • Set display to full screen, but don't "use all monitors"
  • Connect to xrdp, and log in as Xorg 24-bit.
  • Unmaximise the window and drag it to the other monitor
  • Maximise the window

I'll carry on trying to reproduce it with remmina or xfreerdp next week.

@matt335672
Copy link
Member

I've found one reason why this is happening.

When the screen resizes, the xorgxrdp driver enters rdpClientConProcessScreenSizeMsg() twice. The shared memory Id changes twice as a result:-

[ 11703.161] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 1920 cy 1200
[ 11703.161] rdpClientConProcessMsgVersion: version 0 0 0 1
[ 11703.161] rdpClientConProcessScreenSizeMsg: set width 1920 height 1200 bpp 24
[ 11703.162] rdpClientConProcessScreenSizeMsg: shmemid 98335 shmemptr 0x7fdd99533000
[ 11703.162] rdpRRScreenSetSize: width 1920 height 1200 mmWidth 508 mmHeight 318
[ 11703.162] rdpRRGetInfo:
[ 11703.162]   screen resized to 1920x1200
[ 11703.162] rdpClientConProcessScreenSizeMsg: RRScreenSizeSet ok=[1]
[ 11703.164] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 1920 cy 1200
[ 11703.164] rdpClientConProcessMsgClientInfo:
[ 11703.164]   got client info bytes 7072
[ 11703.164]   jpeg support 0
[ 11703.164]   offscreen support 1
[ 11703.164]   offscreen size 7864320
[ 11703.164]   offscreen entries 100
[ 11703.164]   client can not do offscreen to offscreen blits
[ 11703.164]   client can do new(color) cursor
[ 11703.164]   client can not do multimon
[ 11703.164] rdpRRSetRdpOutputs: numCrtcs 1 numOutputs 1 monitorCount 0
[ 11703.164] rdpRRSetRdpOutputs: update output 0 left 0 top 0 width 1920 height 1200
[ 11703.164] rdpRRUpdateOutput:
[ 11703.165] rdpLoadLayout: keylayout 0x00000809 variant  display 12
[ 11703.165] rdpkeybChangeKeyboardControl:
[ 11703.165] rdpkeybChangeKeyboardControl: autoRepeat on
[ 11703.166] rdpkeybChangeKeyboardControl:
[ 11703.166] rdpkeybChangeKeyboardControl: autoRepeat on
[ 11703.174] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 1920 cy 1200
[ 11703.175] rdpClientConProcessMsgVersion: version 0 0 0 1
[ 11703.175] rdpClientConProcessScreenSizeMsg: set width 1920 height 1200 bpp 24
[ 11703.176] rdpClientConProcessScreenSizeMsg: shmemid 98336 shmemptr 0x7fdd99533000
[ 11703.176] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 1920 cy 1200
[ 11703.177] rdpClientConRecv: g_sck_recv failed(returned -1)

In this example the shared memory ID changes to 98335, and then to 98336.

The xup routine process_server_paint_rect_shmem_ex() then gets a call to draw into shared memory ID 98335. It tries to map this, and fails, as it no longer exists. As a result, the call exits with an error.

Fix is probably not to re-allocate the memory region if it will be exactly the same size. I'll add a PR for this tomorrow to xorgxrdp for review.

@matt335672
Copy link
Member

matt335672 commented Dec 1, 2021

After retesting with neutrinolabs/xorgxrdp#203, I've found that there are other causes for this problem.

neutrinolabs/xorgxrdp#203 seems to fix the problem provided I build without RFX enabled. Once RFX is enabled, the client exits on resize after sending a TS_CONFIRM_ACTIVE_PDU. I'll carry on digging.

@Nexarian
Copy link
Contributor

Nexarian commented Dec 2, 2021

@matt335672 I think the cause may be an issue that plagues the resize code in general. When resizing is enabled, in addition to the initial screen connection most clients send a second resize message on the DISPLAY channel to resize to the same value.

In the prototype I have where this works with EGFX, I solved this by refactoring the resizing code so that when a display resize comes in it's not processed immediately, but instead is added to a queue that is then processed as a state machine using wait objects. The queue is pre-populated with a NULL value that automatically rejects the first message on startup.

This might also be the fix we need to proceed with here. Thoughts?

@matt335672
Copy link
Member

This is not quite the same - I'm getting two identical DISPLAYCONTROL_MONITOR_LAYOUT_PDUs for the same size on the DISPLAY channel in quick succession when I go full-size on a single screen (and not before). I set a breakpoint on dynamic_monitor_data() and that's what I see. It looks like something the mstsc.exe program is doing.

If your state machine handles that, we can look at a PR to get the SM in now. It might make merging your code later a little easier. Are you able to reproduce this fault?

With neutrinolabs/xorgxrdp#203, everything seems solid with mstsc.exe and moving single screens about until I enable RFX. At that point, following the resize, we're sending the client something it doesn't like, and the client exits. So that's something that needs to be located anyway.

While we're in that area, am I correct in thinking that xorgxrdp and the xup module always used shared memory? I need to know that to fully address neutrinolabs/xorgxrdp#199. I'm pretty sure it's the case, but I'd value a confirmation from someone who understands this a bit better.

@Nexarian
Copy link
Contributor

Nexarian commented Dec 6, 2021

Ah, I never actually fully tested the resize code with MSTSC as its feature set was woefully incomplete, but I agree we need to test it. Do I NEED two non-identical monitors? If I do, that's slightly annoying. Maybe I can just change the resolution of one of them.

As to xup and xorgxrdp, the only caveat in what you said is "ALWAYS" with shared memory. I'm not sure it's always, but I've never seen an exception to it. I would say let's assume that to be true unless we find evidence otherwise.

My state machine code would solve the case of multiple resize messages that are all the same, as well, because the first condition of rejection of an item on the queue is if it's trying to resize to the same thing that already exists. It will add it to the queue, process the first resize, then delete the second. In any case the state machine code is broken up over several bits. We'll need to adapt it for non-GFX use cases for now. I'll post a description of how it works in the Gitter. I want us to make sure we're all on board with this architecture in case changes need to be made. Here are the most significant parts in my view.

https://github.com/Nexarian/xrdp/blob/resize_egfx_nvenc_helper_features/xrdp/xrdp_mm.c#L1441
https://github.com/Nexarian/xrdp/blob/resize_egfx_nvenc_helper_features/xrdp/xrdp_mm.c#L1451
https://github.com/Nexarian/xrdp/blob/resize_egfx_nvenc_helper_features/xrdp/xrdp_mm.c#L1504
https://github.com/Nexarian/xrdp/blob/resize_egfx_nvenc_helper_features/xrdp/xrdp_mm.c#L3196
https://github.com/Nexarian/xrdp/blob/resize_egfx_nvenc_helper_features/common/xrdp_client_info.h#L49
https://github.com/Nexarian/xrdp/blob/resize_egfx_nvenc_helper_features/xup/xup.c#L1597 (Note: This is part of Jay's new xorgxrdp_helper system, but we should still consider implementing this signal as it's essentially a pass-through from xorgxrdp. This forces the state machine to wait until xorgxrdp has ACTUALLY resized the shared memory. This was causing instability until I fixed this.)

@matt335672
Copy link
Member

I appreciate this is complicated. If we can merge incoming stuff to fix this issue, it should make our lives easier moving forward, so I'm up for that.

This is the only situation I've seen where mstsc.exe sends a resize request.

If you're going to test your state machine with this, the two use-cases are "monitors are different resolutions", and "monitors are the same resolution". So if you've got two the same and you can set the resolution on one down a bit, that will cover both use-cases. Sounds ideal.

I've got a twin-monitor VM which I use to test this stuff. That's another way to do it, but it's fiddly to set up,

By all means post a description on Gitter, but I think the final place for designs should probably be the Wiki, as it gets really hard to find stuff on Gitter after some time has elapsed. I appreciate that this is likely to be complex.

As well as the resolution changing, we probably need to support a use-case where the resolution stays the same but the monitor size changes (i.e. the user moves the screen from a 25-inch 1920x1080 monitor to a 27-inch 1920x1080 monitor. At least the xrandr protocol allows that to happen. That may be awkward to test.

The reason I'm keen on knowing whether we always use shared memory is to be able to put neutrinolabs/xorgxrdp#199 to bed. Also, if we always use shared memory, the use-case of running xrdp on one machine and sesman on another goes away, which makes a move to UNIX domain sockets for IPC a bit easier - we know virtually no-one will be using the split-machine use-case.

@jsorg71 - can you advise as as to whether we can safely assume that the xup/xorgxrdp interface always uses shared memory?

@Nexarian
Copy link
Contributor

I just tested this with single-monitor:

  1. Maximize MSTSC
  2. Restore it to smaller resolution
  3. Change monitor resolution
  4. Maximize MSTSC again

This works, now to test more complex use-cases...

@Nexarian
Copy link
Contributor

Ok, this seems to ONLY reproduce on systems that have more than one monitor for the client. I think, unfortunately, this is a gap in my original code. I was sorta hand-wavy about the way I handled the multi-mon situation because in general if we're resizing, the assumption is we revert to only one monitor. As you know some of my other PRs that are in the works are meant to deal with this issue explicitly, so I think I need to work on cleaning up this entire space. Both improved handling of the DISPLAY_CONTROL PDU (unified with the legacy messages for multi-mon) as well as the queue approach should help this.

@matt335672
Copy link
Member

Glad you found it - that's the only way I could reproduce it too. The duplicate PDUs are definitely causing a problem, but I also saw a couple of crashes that were not related to that.

@Nexarian
Copy link
Contributor

Nexarian commented Mar 31, 2022

@matt335672 Ok, I have made progress on this!

First, with #2175 and neutrinolabs/xorgxrdp#203 combined, MSTSC DOES NOT crash when a performance setting less than "LAN" is used (WAN "10 Mbps or higher with high latency" or lower, that is). Set it to LAN and it does crash.

From my reading of /var/log/xrdp.log, in both cases the RemoteFX codec is being used. Thus, I'm not clear on exactly what the difference is in the protocol or what it is that MSTSC is expecting at higher network bandwidths. I followed these instructions on how to enable error logs from MSTSC in Windows: https://support.oneidentity.com/one-identity-safeguard-for-privileged-sessions/kb/331680/gathering-rdp-event-logs-from-windows-10-machines

Maybe one of you can see something obvious? This is baffling as this resizing code works with FreeRDP, the App Store client, and the Mac OS version of RDP. Unfortunately, MSTSC is the reference implementation, so we need to fix this :/

@Nexarian
Copy link
Contributor

I think this is our answer: #843

I think I know the problem now.

Note that here: https://github.com/neutrinolabs/xrdp/blob/devel/xrdp/xrdp_encoder.c#L92, we create the encoder. And guess what? The encoder's creation is dependent on the size of the session. That means, when we resize, we have to delete and re-create the encoder (https://github.com/neutrinolabs/xrdp/blob/devel/xrdp/xrdp_encoder.c#L142). However, that is only called here right now: https://github.com/neutrinolabs/xrdp/blob/devel/xrdp/xrdp_mm.c#L158

Fortunately, #2175 is the first step to the answer. Add in another state machine step that deletes and then recreates the encoder, and we're good! I already did this for GFX use cases, but I forgot that it also applies to RFX as well!

I'm out of time to work on this tonight, but I'd love your thoughts on if this is the right approach and/or how to change it.

@matt335672
Copy link
Member

I did wonder about the threading maybe being a problem here. If I understand it right (and please tell me if I've got this wrong), the encoder is busy processing the shared memory area when the resize comes in.

If that's the case, you seem to have a couple of options:-

  1. Wait for the encoder to finish its current frame (or kill it somehow) before actioning the resize.

  2. Make sure the encoder's shared memory area is attached and detached separately. Then if a new one is mapped on a resize, the encode will hold the existing one open until it finishes, then you ignore the result.

  3. sounds simpler to me, but I don't know the code anywhere near as well as you do.

@Nexarian
Copy link
Contributor

Look at the code for xrdp_encoder_delete, it addresses all of those concerns for you. It essentially blocks until the encoder is completely shut down and the processing queue is drained. This is what we want. In this way, I don't even have to add a provision to the state machine to wait until the encoder has been deleted (Note that for EGFX, I do, and that's now easy with this architecture), it does that for me. Shared memory is equally handled.

So really all I had to do to fix the LAN resizing crash with MSTSC was to put a delete encoder at the beginning of the resize operation, and a re-create after the resize had finished (right before the invalidate signal is send to xorgxrdp).

Try out #2175 and let me know if you can reproduce the MSTSC crash (with or without RFX). I can't anymore! I believe it's fixed :)

The PR still has a few things that need to be cleaned up, but it's good enough for you to start reviewing it.

@matt335672
Copy link
Member

I've tried PR #2175 on this.

The good news is it doesn't seem to crash any more.

I've also found an off-by-one error. I'll add it to the review of #2175

@Nexarian
Copy link
Contributor

@matt335672 More targeted PR that fixes only this issue: #2291

@Nexarian
Copy link
Contributor

Merged in the fix. I believe this can be resolved. @okhowang can you confirm?

@okhowang
Copy link
Contributor Author

okhowang commented Jun 28, 2022

I use win11 now,
and use two 4K monitor and a 2K miracast notebook for different resolution testing.
there is no internal error, but crash remained.
just without any error window.

test with latest devel
xorgxrdp a4ce59b46867e61ffc7bb630824d764916c78832
xrdp eeb5daa
last log

[691869.436] rdpRRSetRdpOutputs: numCrtcs 1 numOutputs 1 monitorCount 0
[691869.436] rdpRRSetRdpOutputs: update output 0 left 0 top 0 width 2560 height 1440
[691869.436] rdpRRUpdateOutput:
[691869.436] rdpLoadLayout: keylayout 0x00000804 variant  display 12
[691869.436] rdpkeybChangeKeyboardControl:
[691869.436] rdpkeybChangeKeyboardControl: autoRepeat on
[691869.437] rdpkeybChangeKeyboardControl:
[691869.438] rdpkeybChangeKeyboardControl: autoRepeat on
[691869.439] rdpRRGetInfo:
[691869.506] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 2560 cy 1440
[691869.506] rdpClientConProcessMsgVersion: version 0 0 0 1
[691869.507] rdpClientConProcessScreenSizeMsg: set width 2560 height 1440 bpp 32
[691869.509] rdpClientConProcessScreenSizeMsg: shmemid 65578 shmemptr 0x7f241e4fb000
[691869.509] rdpClientConProcessMsgClientInput: invalidate x 0 y 0 cx 2560 cy 1440
[691869.514] rdpRRGetInfo:
[691869.536] rdpInDeferredRepeatCallback:
[691869.536] rdpkeybChangeKeyboardControl:
[691869.536] rdpkeybChangeKeyboardControl: autoRepeat off
[691869.538] rdpInDeferredRepeatCallback:
[691869.538] rdpkeybChangeKeyboardControl:
[691869.538] rdpkeybChangeKeyboardControl: autoRepeat off
[691870.456] rdpClientConRecv: g_sck_recv failed(returned -1)
[691870.456] rdpClientConRecvMsg: error
[691870.456] rdpClientConCheck: rdpClientConGotData failed
[691870.456] rdpClientConDisconnect:
[691870.456] rdpRemoveClientConFromDev: removing clientCon 0x557d77c2b1e0

@Nexarian
Copy link
Contributor

@okhowang What were the exact steps you used to reproduce this crash?

@Nexarian Nexarian reopened this Jun 28, 2022
@okhowang
Copy link
Contributor Author

  1. install latest devel xrdp and xorgxrdp
  2. startup xrdp ./xrdp
  3. connect with mstsc version windows 11 21H2 20000.778. options fullscreen and LAN 32bpp
  4. mstsc work well on one 4K monitor
  5. move mstsc to 2K monitor and make it fullscreen.
  6. mstsc crash without any error tips.

@metalefty
Copy link
Member

You pasted xorgxrdp log so did you mean xorgxrdp craches? The fix @Nexarian provided is for xrdp crash.

@okhowang
Copy link
Contributor Author

You pasted xorgxrdp log so did you mean xorgxrdp craches? The fix @Nexarian provided is for xrdp crash.

no, I dont' known which component went wrong.

here is xrdp.log

[20220628-10:22:33] [INFO ] loaded module 'libxup.so' ok, interface size 10400, version 4
[20220628-10:22:33] [INFO ] started connecting
[20220628-10:22:33] [INFO ] lib_mod_connect: connecting via UNIX socket
[20220628-10:22:33] [INFO ] lib_mod_log_peer: xrdp_pid=8736 connected to X11rdp_pid=4532 X11rdp_uid=1001 X11rdp_gid=1001 client=10.6.52.40:62690
[20220628-10:22:33] [INFO ] connected ok
[20220628-10:22:39] [WARN ] libxrdp_process_monitor_stream: desktop_scale_factor is not within valid range. Assuming 100. Value was: 200
[20220628-10:22:40] [WARN ] libxrdp_process_monitor_stream: desktop_scale_factor is not within valid range. Assuming 100. Value was: 200
[20220628-10:22:41] [ERROR] Can't attach to shared memory id 65573 from id 65569 [Invalid argument]
[20220628-10:22:41] [ERROR] lib_data_in: lib_mod_process_message failed
[20220628-10:22:41] [ERROR] SSL_shutdown: I/O error

and xrdp-sesman.log

[20220628-10:22:33] [INFO ] Socket 13: connection accepted from AF_UNIX
[20220628-10:22:33] [INFO ] Received request to create Xorg session for user: okhowang
[20220628-10:22:33] [INFO ] ++ reconnected session: username okhowang, display :12.0, session_pid 4530, ip 10.6.52.40
[20220628-10:22:33] [INFO ] Starting session reconnection script on display 12: /etc/xrdp/reconnectwm.sh
[20220628-10:22:33] [INFO ] Process 8744 has exited
[20220628-10:22:33] [ERROR] sesman_main_loop: trans_check_wait_objs failed, removing trans

@Nexarian Nexarian changed the title crash when resoltion changed MSTSC crashes when resolution is changed by maximizing on a different monitor Jun 28, 2022
@Nexarian
Copy link
Contributor

Can't attach to shared memory id 65573 from id 65569 That is an interesting log statement, and may lead us to the answer here.

@metalefty
Copy link
Member

@Nexarian I tried with another external display, I confirmed the crash still remained. It is almost same as @okhowang said but it is not 100% for me.

@Nexarian
Copy link
Contributor

Another tidbit from the logs is the scale factor. The 4K display is scaled. If you set the 4K display to a scale factor of 100% instead of the default 200% does this still happen?

If not, then we need to work on incorporating this fix: #1692

@okhowang
Copy link
Contributor Author

I use two 4K monitor with 200% scale.
And I change one to 1080p with 100% scale.
when I move fullscreen-mstsc from 4K/200% to 1080p/100%, it works well.
but from 1080p/100% to 4K/200%, it crash.

@Nexarian
Copy link
Contributor

Then I have enough to reproduce this. Give me a few days to test this. I have to dig out my old 1080p monitor :)

@Nexarian
Copy link
Contributor

Nexarian commented Jul 2, 2022

Was able to reproduce this. You don't actually need a 4K monitor and an HD monitor. You just need to have 2x monitors next to each other. Here's my setup, note that both of these monitors are actually 2560x1440 native, you just change the resolution of one of them to both a different resolution AND a different scale. If you just change the scale but not the resolution, nothing changes.

Monitor 1: 2560x1440 @ 100%
Monitor 2: 1920x1080 @ 175%

Connect with MSTSC maximized on Monitor 1. Restore, move to Monitor 2, then Maximize.

Result: MSTSC connection drops, but no error message is broadcasted.

@Nexarian
Copy link
Contributor

Nexarian commented Jul 2, 2022

I suspect in order to fully fix this we have to finish: neutrinolabs/xorgxrdp#172

However, there may be a way to at least make sure the session doesn't crash...

Nexarian added a commit to Nexarian/xrdp that referenced this issue Jul 2, 2022
While this feature is part of other branches for testing EGFX
integration, it somehow never made it into devel. This should fix

neutrinolabs#1928, for real this time!
Nexarian added a commit to Nexarian/xrdp that referenced this issue Jul 2, 2022
While this feature is part of other branches for testing EGFX
integration, it somehow never made it into devel. This should fix
neutrinolabs#1928, for real this time!
@Nexarian
Copy link
Contributor

Nexarian commented Jul 2, 2022

@okhowang Actually we don't need neutrinolabs/xorgxrdp#172 to fix this. Turns out the reason this is happening is due to a bug I fixed long ago in my https://github.com/Nexarian/xrdp/tree/mainline_merge branch, and for some reason it didn't make it over!

@Nexarian
Copy link
Contributor

Nexarian commented Jul 2, 2022

@metalefty @matt335672 @okhowang Please test and let me know if #2300 fixes this for you.

Nexarian added a commit to Nexarian/xrdp that referenced this issue Jul 2, 2022
While this feature is part of other branches for testing EGFX
integration, it somehow never made it into devel. This should fix
neutrinolabs#1928, for real this time!
@okhowang
Copy link
Contributor Author

okhowang commented Jul 3, 2022

@metalefty @matt335672 @okhowang Please test and let me know if #2300 fixes this for you.

Nexarian/block_resize_if_already_resized works for me

@Nexarian
Copy link
Contributor

Nexarian commented Jul 3, 2022

Excellent, I'll wait for someone to review it before merging. Until then, enjoy!

I think I've found a way to make the DPI scaling work as well. More info here: #1612

derekschrock pushed a commit to derekschrock/xrdp that referenced this issue Dec 15, 2022
While this feature is part of other branches for testing EGFX
integration, it somehow never made it into devel. This should fix
neutrinolabs#1928, for real this time!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants