Skip to content

Segfault at startup under XWayland (GDK_BACKEND=x11)

It appears that under XWayland (i.e. with GDK_BACKEND=x11 in the environment), xfce4-terminal attempts to call XOpenDisplay("wayland-0"), which fails and leads to a segfault.

Backtrace:

Thread 1 "xfce4-terminal" received signal SIGSEGV, Segmentation fault.
0x00007ffff6e1d0a6 in pthread_cond_destroy@@GLIBC_2.3.2 () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff6e1d0a6 in pthread_cond_destroy@@GLIBC_2.3.2 () at /usr/lib/libc.so.6
#1  0x00007ffff7e97b1f in _XFreeX11XCBStructure () at /usr/lib/libX11.so.6
#2  0x00007ffff7e8745f in _XFreeDisplayStructure () at /usr/lib/libX11.so.6
#3  0x00007ffff7e87e82 in XOpenDisplay () at /usr/lib/libX11.so.6
#4  0x00007ffff758dd8e in  () at /usr/lib/libgdk-3.so.0
#5  0x00007ffff753ac6e in gdk_display_manager_open_display () at /usr/lib/libgdk-3.so.0
#6  0x0000555555565683 in terminal_app_find_display (display_name=0x55555574a150 "wayland-0", screen_num=screen_num@entry=0x7fffffffe6e0) at terminal-app.c:666
#7  0x0000555555565b19 in terminal_app_find_screen_by_name (display_name=<optimized out>) at terminal-app.c:712
#8  terminal_app_open_window (app=app@entry=0x555555639b20, attr=attr@entry=0x5555557f0b00) at terminal-app.c:833
#9  0x000055555556644e in terminal_app_process (app=app@entry=0x555555639b20, argv=argv@entry=0x5555555e8020, argc=argc@entry=4, error=error@entry=0x7fffffffe7b0) at terminal-app.c:1014
#10 0x0000555555564700 in main (argc=<optimized out>, argv=<optimized out>) at main.c:335

The root cause of the issue appears to be that xfce4-terminal always prefers WAYLAND_DISPLAY over DISPLAY if both are set, regardless of the GDK backend in use. A potential fix is to get the default display name from GDK rather than trying to determine it from the environment variables directly. See the attached patch.

0001-Fix-startup-with-GDK_BACKEND-x11.patch