FreeRDP: [client,SDL] Auto-reconnect causes a segmentation fault

Describe the bug FreeRDP throws a segmentation fault when trying to reconnect to an AVD server.

[14:13:59:148] [116776:0001c828] [ERROR][com.freerdp.core.transport] - [transport_default_write]: BIO_write returned a system error 32: Broken pipe
[14:13:59:151] [116776:0001c82f] [ERROR][com.freerdp.core] - [transport_read_layer]: ERRCONNECT_CONNECT_TRANSPORT_FAILED [0x0002000D]
[14:13:59:155] [116776:0001c828] [ERROR][com.freerdp.core] - [transport_default_write]: ERRCONNECT_CONNECT_TRANSPORT_FAILED [0x0002000D]
[14:13:59:155] [116776:0001c828] [ERROR][com.freerdp.core] - [transport_default_write]: TODO: Trying to set error code ERRCONNECT_CONNECT_TRANSPORT_FAILED, but ERRCONNECT_CONNECT_TRANSPORT_FAILED already set!
[14:13:59:155] [116776:0001c828] [ERROR][com.freerdp.core.transport] - [transport_default_write]: BIO_should_retry retries exceeded
[14:13:59:156] [116776:0001c828] [ERROR][com.freerdp.core.transport] - [transport_default_write]: BIO_should_retry retries exceeded
[14:13:59:156] [116776:0001c828] [ERROR][com.freerdp.core.transport] - [transport_default_write]: BIO_should_retry retries exceeded
[14:13:59:156] [116776:0001c828] [ERROR][com.freerdp.core.transport] - [transport_default_write]: BIO_should_retry retries exceeded
[14:13:59:167] [116776:0001c828] [ERROR][com.freerdp.core.transport] - [transport_default_write]: BIO_should_retry retries exceeded
[14:13:59:634] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [fatal_handler]: Caught signal 'Segmentation fault' [11]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 0: dli_fname=/opt/freerdp-nightly-selfbuild/bin/../lib/libwinpr3.so.3 [0x7202e4000000], dli_sname=winpr_backtrace [0x7202e416dce0]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 1: dli_fname=/opt/freerdp-nightly-selfbuild/bin/../lib/libwinpr3.so.3 [0x7202e4000000], dli_sname=winpr_log_backtrace_ex [0x7202e416e860]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 2: dli_fname=/opt/freerdp-nightly-selfbuild/bin/../lib/libfreerdp3.so.3 [0x7202e4400000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 3: dli_fname=/lib/x86_64-linux-gnu/libc.so.6 [0x7202e3800000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 4: dli_fname=/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 [0x7202e4c60000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 5: dli_fname=/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 [0x7202e4c60000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 6: dli_fname=/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 [0x7202e4c60000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 7: dli_fname=/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 [0x7202e4c60000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 8: dli_fname=/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 [0x7202e4c60000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 9: dli_fname=/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 [0x7202e4c60000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 10: dli_fname=/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 [0x7202e4c60000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 11: dli_fname=/lib/x86_64-linux-gnu/libSDL2-2.0.so.0 [0x7202e4c60000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 12: dli_fname=/opt/freerdp-nightly-selfbuild/bin/sdl-freerdp [0x5e94ac01c000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 13: dli_fname=/opt/freerdp-nightly-selfbuild/bin/sdl-freerdp [0x5e94ac01c000], dli_sname=main [0x5e94ac039370]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 14: dli_fname=/lib/x86_64-linux-gnu/libc.so.6 [0x7202e3800000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 15: dli_fname=/lib/x86_64-linux-gnu/libc.so.6 [0x7202e3800000], dli_sname=__libc_start_main [0x7202e3829dc0]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 16: dli_fname=/opt/freerdp-nightly-selfbuild/bin/sdl-freerdp [0x5e94ac01c000], dli_sname=(null) [(nil)]
[14:13:59:647] [116776:0001c828] [ERROR][com.freerdp.utils.signal] - [winpr_log_backtrace_ex]: 17: unresolvable, address=(nil)

To Reproduce Steps to reproduce the behavior:

  1. Connect to an AVD.
  2. Wait for one hour.
  3. Disable the network connection (Wi-Fi, LAN).
  4. ~Turn on the connection.~ Wait a couple minutes.
  5. See the stack trace.

Expected behavior At least, no stack trace.

Application details

  • FreeRDP version (xfreerdp /version): This is FreeRDP version 3.9.1-dev0 (f1725b2d9)
  • Command line used: /opt/freerdp-nightly-selfbuild/bin/sdl-freerdp <file>.rdpw /gateway:type:arm /size:1366x768 /f /u:<user> /p:'<password>' /mic:sys:pulse,format:1 /auto-reconnect /dvc:rdpecam -decorations
  • Output of xfreerdp /buildconfig:
Details
This is FreeRDP version 3.9.1-dev0 (f1725b2d9)                                                   
Build configuration: BUILD_TESTING=OFF WINPR_HAVE_AIO_H=1 WINPR_HAVE_EXECINFO_BACKTRACE=1 WINPR_HAVE_EXECINFO_BACKTRACE_SYMBOLS=1 WINPR_HAVE_EXECINFO_BACKTRACE_SYMBOLS_FD=1 WINPR_HAVE_EXECINFO_HEADER=1 WINPR_HAVE_FCNTL_H=1 WINPR_HAVE_GETLOGIN_R=1 WINPR_HAVE_GETPWUID_R=1 WINPR_HAVE_INTTYPES_H=1 WINPR_HAVE_POLL_H=1 WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIB=1 WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_LIBS= WINPR_HAVE_PTHREAD_MUTEX_TIMEDLOCK_SYMBOL=1 WINPR_HAVE_STDBOOL_H=1 WINPR_HAVE_STDINT_H=1 WINPR_HAVE_STRERROR_R=1 WINPR_HAVE_STRNDUP=1 WINPR_HAVE_SYSLOG_H=1 WINPR_HAVE_SYS_EVENTFD_H=1 WINPR_HAVE_SYS_FILIO_H= WINPR_HAVE_SYS_SELECT_H=1 WINPR_HAVE_SYS_SOCKIO_H= WINPR_HAVE_SYS_TIMERFD_H=1 WINPR_HAVE_TM_GMTOFF=1 WINPR_HAVE_UNISTD_H=1 WINPR_HAVE_UNWIND_H=1 WITH_AAD=ON WITH_ABSOLUTE_PLUGIN_LOAD_PATHS=ON WITH_ADD_PLUGIN_TO_RPATH=OFF WITH_ALSA=ON WITH_AVX2=OFF WITH_AVX2_AVAILABLE=0 WITH_BINARY_VERSIONING=OFF WITH_CAIRO=ON WITH_CCACHE=OFF WITH_CHANNELS=ON WITH_CJSON_REQUIRED=OFF WITH_CLANG_FORMAT=ON WITH_CLIENT=ON WITH_CLIENT_AVAILABLE=1 WITH_CLIENT_CHANNELS=ON WITH_CLIENT_CHANNELS_AVAILABLE=1 WITH_CLIENT_COMMON=ON WITH_CLIENT_INTERFACE=OFF WITH_CLIENT_SDL=ON WITH_CLIENT_SDL2=ON WITH_CLIENT_SDL3=OFF WITH_CLIENT_SDL_AVAILABLE=1 WITH_CLIENT_SDL_VERSIONED=OFF WITH_CUPS=ON WITH_DEBUG_ALL=ON WITH_DEBUG_CAPABILITIES=ON WITH_DEBUG_CERTIFICATE=ON WITH_DEBUG_CHANNELS=ON WITH_DEBUG_CLIPRDR=ON WITH_DEBUG_CODECS=ON WITH_DEBUG_DVC=ON WITH_DEBUG_EVENTS=ON WITH_DEBUG_KBD=ON WITH_DEBUG_LICENSE=ON WITH_DEBUG_MUTEX=ON WITH_DEBUG_NEGO=ON WITH_DEBUG_NLA=ON WITH_DEBUG_
NTLM=ON WITH_DEBUG_RAIL=ON WITH_DEBUG_RDP=ON WITH_DEBUG_RDPDR=ON WITH_DEBUG_RDPEI=ON WITH_DEBUG_RDPGFX=ON WITH_DEBUG_REDIR=ON WITH_DEBUG_RFX=ON WITH_DEBUG_RINGBUFFER=OFF WITH_DEBUG_SCARD=ON WITH_DEBUG_SCHANNEL=ON WITH_DEBUG_SDL_EVENTS=OFF WITH_DEBUG_SDL_KBD_EVENTS=ON WITH_DEBUG_SND=ON WITH_DEBUG_SVC=ON WITH_DEBUG_SYMBOLS=OFF WITH_DEBUG_THREADS=OFF WITH_DEBUG_TIMEZONE=ON WITH_DEBUG_TRANSPORT=ON WITH_DEBUG_TSG=ON WITH_DEBUG_TSMF=OFF WITH_DEBUG_TSMF_AVAILABLE=0 WITH_DEBUG_URBDRC=ON WITH_DEBUG_WND=ON WITH_DEBUG_X11=ON WITH_DEBUG_X11_LOCAL_MOVESIZE=ON WITH_DEBUG_XV=ON WITH_DOCUMENTATION=OFF WITH_DSP_EXPERIMENTAL=OFF WITH_DSP_FFMPEG=ON WITH_DSP_FFMPEG_AVAILABLE=1 WITH_EVENTFD_READ_WRITE=1 WITH_FAAC=OFF WITH_FAAD2=OFF WITH_FDK_AAC=OFF WITH_FFMPEG=ON WITH_FREERDP_DEPRECATED=OFF WITH_FREERDP_DEPRECATED_COMMANDLINE=ON WITH_FULL_CONFIG_PATH=OFF WITH_FUSE=ON WITH_GFX_FRAME_DUMP=OFF WITH_GFX_H264=ON WITH_GPROF=OFF WITH_GSM=OFF WITH_INTERNAL_MD4=OFF WITH_INTERNAL_MD5=OFF WITH_INTERNAL_RC4=OFF WITH_JPEG=OFF WITH_JSONC_REQUIRED=OFF WITH_JSON_DISABLED=OFF WITH_KEYBOARD_LAYOUT_FROM_FILE=OFF WITH_KRB5=ON WITH_KRB5_NO_NTLM_FALLBACK=OFF WITH_LAME=OFF WITH_LIBRARY_VERSIONING=ON WITH_LIBRESSL=OFF WITH_LODEPNG=OFF WITH_MACAUDIO=OFF WITH_MACAUDIO_AVAILABLE=0 WITH_MANPAGES=ON WITH_MBEDTLS=OFF WITH_MS_RDPECAM_CLIENT=ON WITH_NATIVE_SSPI=OFF WITH_NEON=OFF WITH_OPAQUE_SETTINGS=OFF WITH_OPENCL=OFF WITH_OPENH264=OFF WITH_OPENSSL=ON WITH_OPUS=OFF WITH_OSS=ON WITH_PCSC=ON WITH_PKCS11=ON WITH_PLATFORM_SERVER=ON WITH_POLL=ON WITH_PROFILER=OFF WITH_PROXY=ON WITH_PROXY_APP=ON WITH_PROXY_EMULATE_SMARTCARD=OFF WITH_PROXY_MODULES=ON WITH_PULSE=ON WITH_RDTK=ON WITH_SAMPLE=ON WITH_SANITIZE_ADDRESS=ON WITH_SANITIZE_ADDRESS_AVAILABLE=1 WITH_SANITIZE_MEMORY=OFF 
WITH_SANITIZE_MEMORY_AVAILABLE=0 WITH_SANITIZE_THREAD=OFF WITH_SANITIZE_THREAD_AVAILABLE=0 WITH_SDL_IMAGE_DIALOGS=OFF WITH_SDL_LINK_SHARED=ON WITH_SERVER=ON WITH_SERVER_CHANNELS=ON WITH_SERVER_INTERFACE=ON WITH_SHADOW=ON WITH_SMARTCARD_EMULATE=ON WITH_SMARTCARD_INSPECT=OFF WITH_SMARTCARD_PCSC=ON WITH_SOXR=OFF WITH_SSE2=OFF WITH_SWSCALE=ON WITH_SYSTEMD=OFF WITH_THIRD_PARTY=OFF WITH_TIMEZONE_COMPILED=ON WITH_TIMEZONE_FROM_FILE=OFF WITH_TIMEZONE_ICU=OFF WITH_UNICODE_BUILTIN=OFF WITH_URIPARSER=ON WITH_VAAPI=OFF WITH_VAAPI_AVAILABLE=1 WITH_VALGRIND_MEMCHECK=OFF WITH_VALGRIND_MEMCHECK_AVAILABLE=0 WITH_VERBOSE_WINPR_ASSERT=ON WITH_VIDEO_FFMPEG=ON WITH_VIDEO_FFMPEG_AVAILABLE=1 WITH_WAYLAND=ON WITH_WEBVIEW=OFF WITH_WINPR_DEPRECATED=OFF WITH_WINPR_JSON=ON WITH_WINPR_TOOLS=ON WITH_WIN_CONSOLE=ON WITH_X11=ON WITH_XCURSOR=ON WITH_XEXT=ON WITH_XFIXES=ON WITH_XI=ON WITH_XINERAMA=ON WITH_XRANDR=ON WITH_XRENDER=ON WITH_XV=ON
Build type:          RelWithDebInfo
CFLAGS:               -fPIC -Wall -fvisibility=hidden -Wimplicit-function-declaration -Wredundant-decls -g -fno-omit-frame-pointer -fsanitize=address -fsanitize-address-use-after-scope
Compiler:            GNU, 11.4.0       
Target architecture: x64     
  • OS version connecting to (server side): Windows 11
  • If available the log output from a run with /log-level:trace 2>&1 | tee log.txt : Let me know if any details are required.

Environment (please complete the following information):

  • OS: Linux
  • Version/Distribution: Xubuntu 22.04.5 LTS
  • Architecture: x86_64

Additional context The problem is reproduced after #10390. I think this is due to two facts:

  • A Bearer token is provided for an hour, after which it becomes invalid.
  • It can’t be validated/re-requested when the connection is down? Perhaps this case is not considered, so FreeRDP keeps trying to use it, but with no success.

FreeRDP reconnects to a AVD with no problem if I connected to the server 5-10 minutes ago. That’s why I suspect token lifetime.

P.S. How long has it been since I created the last issue? I noticed the problem right after the PR, but was too busy to create a issue 😕

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 94 (49 by maintainers)

Most upvoted comments

@Iife85dr1 ok, finally managed to reproduce.

fixed in latest commit, please confirm 😁

as for security mode, shold be part of a debug log.

[16:36:12:138] [49652:0000c1fa] [DEBUG][com.freerdp.core.nego] - [nego_set_negotiation_enabled]: Enabling security layer negotiation: TRUE
[16:36:12:138] [49652:0000c1fa] [DEBUG][com.freerdp.core.nego] - [nego_set_restricted_admin_mode_required]: Enabling restricted admin mode: FALSE
[16:36:12:138] [49652:0000c1fa] [DEBUG][com.freerdp.core.nego] - [nego_enable_rdp]: Enabling RDP security: FALSE
[16:36:12:138] [49652:0000c1fa] [DEBUG][com.freerdp.core.nego] - [nego_enable_tls]: Enabling TLS security: FALSE
[16:36:12:138] [49652:0000c1fa] [DEBUG][com.freerdp.core.nego] - [nego_enable_nla]: Enabling NLA security: FALSE
[16:36:12:138] [49652:0000c1fa] [DEBUG][com.freerdp.core.nego] - [nego_enable_ext]: Enabling NLA extended security: FALSE
[16:36:12:138] [49652:0000c1fa] [DEBUG][com.freerdp.core.nego] - [nego_enable_rdstls]: Enabling RDSTLS security: TRUE
[16:36:12:138] [49652:0000c1fa] [DEBUG][com.freerdp.core.nego] - [nego_enable_aad]: Enabling RDS AAD security: FALSE
[16:36:13:509] [49652:0000c1fa] [DEBUG][com.freerdp.core.gcc] - [gcc_read_server_security_data]: Server rdp encryption method: NONE

[edited] on second thought, maybe we should remove that specific signal from the list of termination/fatal termination signals

This bug only with “RDP” security layer

you got the quotes wrong 😉 should read RDP “security” 😁

This bug only with “RDP” security layer

@Iife85dr1 ok, pushed another fix (did review all usages of the streampool functions) can you still reproduce the deadlock?

Yes.

But when i change “require use of specific security layer for remote (rdp) connections” to “SSL” all work fine

@Iife85dr1 ok, got it. the freerdp_client_send_button_event is called from the wrong thread.

And freerdp cmake command

cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_CHANNELS=ON    -DWITH_CLIENT_CHANNELS=ON    -DWITH_CUPS=ON    -DWITH_DSP_FFMPEG=ON    -DWITH_FFMPEG=ON    -DWITH_ICU=ON    -DWITH_JPEG=ON    -DWITH_PCSC=ON    -DWITH_PULSE=ON    -DWITH_SERVER=ON    -DWITH_SERVER_CHANNELS=ON    -DWITH_SWSCALE=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DOPENSSL_ROOT_DIR=/tmp/lib/openssl

https://gitlab.archlinux.org/archlinux/packaging/packages/freerdp2/-/blob/main/PKGBUILD?ref_type=heads

without patches

@progxaker so from the data so far this looks like a SDL bug, but not sure how to trigger

@progxaker hmm, strange. looks like this crashes in the SDL thread when creating a dialog window in a SDL function (SDL_CreateWindowAndRenderer)

[edit] also running it in a debugger (gdb or lldb) might help here as we’re missing function names and therefore the trace is not very helpful.

I just remember that there was a parameter you gave me, after which I was getting a specific line like #2 0x7f1dc58a822a in freerdp_client_rdp_file_set_string ../client/common/file.c:675 (#9208)… You may have disabled this. UPD: oh, it was for the leak sanitizer)

In any case, I will try to gather the information and provide it to you.