Control: retitle -1 scim-gtk-immodule: assumes windowing system is X11, segfaults if not Control: reassign -1 scim-gtk-immodule 1.4.18+git20211204-0.1 Control: affects -1 + src:gtk4 Control: severity -1 important
On Mon, 31 Jul 2023 at 20:57:25 +0200, Michał Byrecki wrote: > > (org.gnome.Nautilus:51577): GLib-GObject-WARNING **: 20:53:04.844: > > invalid cast from 'GdkWaylandToplevel' to 'GdkX11Surface' > > > > (org.gnome.Nautilus:51577): GLib-GObject-WARNING **: 20:53:04.844: > > invalid cast from 'GdkWaylandDisplay' to 'GdkX11Display' These warnings indicate that a component is assuming that all windows are X11 windows, and all displays are X11 displays; and that's also the cause of the segfault, while calling XGetWindowAttributes on something that is not a valid X11 window (probably a null pointer dereference). > > #1 0x00007ffff070d467 in () at > > /usr/lib/x86_64-linux-gnu/gtk-4.0/4.0.0/immodules/libim-scim.so This component seems to be the one that is making that assumption. The bug affects multiple GTK 4 apps because it's a module that has been loaded into GTK 4. Looking at scim-gtk-immodule's GTK 4 code in <https://github.com/scim-im/scim/commit/d35bf5d331d885e94914fea6eab9c56f20666c8d>, it does things like this: > #ifdef GDK_WINDOWING_X11 > GdkX11Display *display = NULL; > > if (widget != NULL) { > display = GDK_X11_DISPLAY (gtk_widget_get_display(widget)); > } else { > display = GDK_X11_DISPLAY (gdk_display_get_default ()); > } That's not correct code: just because the X11 windowing system is compiled into GTK, that doesn't mean it is the one currently in use. The GdkDisplay object might be a GdkX11Display, but equally it might be a GdkWaylandDisplay. (That's why GDK_BACKEND=x11 is a workaround for this, because when that environment variable is set, the X11 windowing system *is* the one in use.) I haven't checked what scim-gtk-immodule does for GTK 3, but if it has the same pattern there, it would be equally problematic for GTK 3. The correct pattern is more like this: GdkDisplay *display; if (widget != NULL) { display = gtk_widget_get_display (widget)); } else { display = gdk_display_get_default (); } #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (display) { GdkX11Display *x11_display = GDK_X11_DISPLAY (display); /* ... do X11 things with x11_display ... */ } #endif #ifdef GDK_WINDOWING_WAYLAND if (GDK_IS_WAYLAND_DISPLAY (display) { GdkWaylandDisplay *wayland_display = GDK_WAYLAND_DISPLAY (display); /* ... do Wayland things with wayland_display ... */ } #endif Until scim-gtk-immodule is fixed, the workaround would be to either set GDK_BACKEND=x11, or use an X11 desktop environment or a desktop environment in X11 mode (like the "GNOME (Xorg)" option for GNOME), or remove scim-gtk-immodule and use a different input method framework such as ibus. ibus is the input method framework recommended by GNOME upstream. I can't read or write any of the languages supported by scim myself, but many of the input methods available for scim seem to be available for ibus too, for example ibus-anthy seems to be the ibus equivalent of scim-anthy. smcv