We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3642

Summary: SDL2 games crash with dbus assertion when Fcitx support is enabled
Product: SDL Reporter: hdack58
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.5   
Hardware: x86_64   
OS: Linux   

Description hdack58 2017-05-03 10:45:59 UTC
Distribution: Arch Linux (Linux 4.10.13)
Desktop Environment: Gnome 3.24.1
dbus version: 1.10.18
SDL2 version: 2.0.5

When running certain SDL2 based games, each game fails to run citing
a dbus assertion:

~~~

process #####: arguments to dbus_message_new_method_call() were incorrect, assertion "_dbus_check_is_valid_path (path)" failed in file dbus-message.c line 1371.
This is normally a bug in some application using the D-Bus library.
  D-Bus not built with -rdynamic so unable to print a backtrace

~~~

My current workaround is to recompile the game against SDL1 or to recompile
SDL2 without Fcitx support -- this allows each game to run.

Installing Fcitx does not resolve this issue. I haven't tested with running
Fcitx as I'm currently using ibus.

Note: Bug #3580 presents a similiar message, but for a different dbus function.

# eduke32 (20170409.r6113-2)

Launches fine with pre-game setup window. Clicking "Start" causes the game to
crash with the above dbus assert message.

Recompiled against SDL version 1.2.15, runs fine.

# gzdoom (3.0pre.101.g43fc5633a-1)

Game crashes shortly after launch. Presents the above dbus assert message.

Recompiled SDL2 with distro's preferred method (see PKGBUILD below) and enabled
debugging symbols. Re-ran gzdoom and got the GDB backtrace below:

~~~

Thread 1 "gzdoom" received signal SIGABRT, Aborted.
0x00007ffff5f92a10 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff5f92a10 in raise () at /usr/lib/libc.so.6
#1  0x00007ffff5f9413a in abort () at /usr/lib/libc.so.6
#2  0x00007fffeee06864 in  () at /usr/lib/libdbus-1.so.3
#3  0x00007fffeedfd60c in  () at /usr/lib/libdbus-1.so.3
#4  0x00007fffeedede62 in dbus_message_new_method_call () at /usr/lib/libdbus-1.so.3
#5  0x00007ffff7b8af0b in FcitxClientICNewMethod (method=<optimized out>, client=0x7ffff7dd93c0 <fcitx_client>) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/core/linux/SDL_fcitx.c:239
#6  0x00007ffff7b8af0b in FcitxClientICCallMethod (method=<optimized out>, client=0x7ffff7dd93c0 <fcitx_client>) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/core/linux/SDL_fcitx.c:251
#7  0x00007ffff7b79206 in X11_DispatchEvent (_this=_this@entry=0x240f180) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/video/x11/SDL_x11events.c:710
#8  0x00007ffff7b7a040 in X11_PumpEvents (_this=0x240f180) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/video/x11/SDL_x11events.c:1407
#9  0x00007ffff7b05407 in SDL_PumpEvents_REAL () at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/events/SDL_events.c:401
#10 0x00007ffff7b05455 in SDL_WaitEventTimeout_REAL (event=0x7fffffffc2a0, timeout=0) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/events/SDL_events.c:436
#11 0x000000000054b624 in I_GetEvent() ()
#12 0x000000000073e735 in NetUpdate() ()
#13 0x000000000073f3ea in TryRunTics() ()
#14 0x0000000000738a2b in D_DoomLoop() ()
#15 0x000000000073a5f3 in D_DoomMain() ()
#16 0x000000000053594e in main ()

~~~

# testgl2

Running the test program 'testgl2' from SDL2 sources also presents the above
dbus assert message, along with a similar looking backtrace too:

~~~

Thread 1 "testgl2" received signal SIGABRT, Aborted.
0x00007ffff7439a10 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff7439a10 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff743b13a in abort () from /usr/lib/libc.so.6
#2  0x00007ffff4ca9864 in ?? () from /usr/lib/libdbus-1.so.3
#3  0x00007ffff4ca060c in _dbus_warn_check_failed () from /usr/lib/libdbus-1.so.3
#4  0x00007ffff4c90e62 in dbus_message_new_method_call () from /usr/lib/libdbus-1.so.3
#5  0x00007ffff7b8af0b in FcitxClientICNewMethod (method=<optimized out>, client=0x7ffff7dd93c0 <fcitx_client>) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/core/linux/SDL_fcitx.c:239
#6  FcitxClientICCallMethod (method=<optimized out>, client=0x7ffff7dd93c0 <fcitx_client>) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/core/linux/SDL_fcitx.c:251
#7  0x00007ffff7b79206 in X11_DispatchEvent (_this=_this@entry=0x616ab0) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/video/x11/SDL_x11events.c:710
#8  0x00007ffff7b7a040 in X11_PumpEvents (_this=0x616ab0) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/video/x11/SDL_x11events.c:1407
#9  0x00007ffff7b05407 in SDL_PumpEvents_REAL () at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/events/SDL_events.c:401
#10 0x00007ffff7b05455 in SDL_WaitEventTimeout_REAL (event=0x7fffffffd660, timeout=0) at /tmp/makepkg/sdl2-debug/src/SDL2-2.0.5/src/events/SDL_events.c:436
#11 0x0000000000403240 in main (argc=<optimized out>, argv=<optimized out>) at testgl2.c:382

~~~

Several other test programs, 'testdraw2', 'testkeys', 'testoverlay2', also
crash; but not programs like 'testnative' or 'loopwave'.

# PKGBUILD

SDL2 (2.0.5) is compiled on Arch Linux with the following flags by default:
(without debugging symbols)

--enable-sdl-dlopen
--disable-arts --disable-esd --disable-nas
--enable-alsa --enable-pulseaudio-shared
--enable-video-wayland
--enable-ibus --enable-fcitx
--disable-rpath

Source: PKGBUILD https://git.archlinux.org/svntogit/packages.git/tree/trunk?h=packages/sdl2
Comment 1 Ryan C. Gordon 2017-05-28 21:13:57 UTC
This is working, with both the 2.0.5 release and the latest in revision control, on Ubuntu 17.04. Messages are passing over dbus to fcitx, and the testime app is getting composed Unicode text back from it. No crashes or warnings.

Is it possible that the fcitx package in Arch has different dbus method signatures, due to a newer/older version of fcitx?

I'll try to get Arch installed and take a look.

--ryan.
Comment 2 Ryan C. Gordon 2017-05-29 06:27:45 UTC
Oh oh oh, I figured it out!

Here's the reproduction case:
- Install fcitx
- Install or build an SDL with fcitx support.
- Uninstall fcitx, or just kill its processes.
- Export SDL_IM_MODULE=fcitx and run an SDL app.
- Get this crash.

(SDL also looks at the XMODIFIERS environment var, and might choose fcitx support from there.)

Basically, if SDL decides to use fcitx, it makes a D-Bus call to create an IC, and doesn't check if this fails. If it fails, future D-Bus method calls to that never-successfully-created D-Bus path will cause this assertion. SDL makes that D-Bus method call on each keypress.

Most people won't see this bug because you need an unlikely set of preconditions (fcitx support but no running fcitx daemon plus the environment variables).

Fix incoming.

--ryan.
Comment 3 Ryan C. Gordon 2017-05-29 07:06:28 UTC
Fixed in https://hg.libsdl.org/SDL/rev/dc895d39212c

--ryan.