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

SDL crashes when accessing IBUS (with workaround) #2941

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 2 comments
Closed

SDL crashes when accessing IBUS (with workaround) #2941

SDLBugzilla opened this issue Feb 11, 2021 · 2 comments
Labels
Milestone

Comments

@SDLBugzilla
Copy link
Collaborator

@SDLBugzilla SDLBugzilla commented Feb 11, 2021

This bug report was migrated from our old Bugzilla tracker.

Reported in version: 2.0.8
Reported for operating system, platform: Linux, x86

Comments on the original bug report:

On 2018-07-15 01:46:51 +0000, wrote:

When starting simutrans game I get an error from dbus which seems to complain about some ibus message. (I don’t know what ibus is for, but this isn’t important here). Error message and backtrace follow:

dbus[8517]: arguments to dbus_message_new_method_call() were incorrect, assertion "path != NULL" failed in file dbus-message.c line 1362.
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

Program received signal SIGABRT, Aborted.
0xb7fd5d41 in __kernel_vsyscall ()
(gdb) bt
# 0  0xb7fd5d41 in __kernel_vsyscall ()
# 1  0xb79d7132 in raise () from /lib/libc.so.6
# 2  0xb79bf7e8 in abort () from /lib/libc.so.6
# 3  0xb74ab34a in _dbus_abort () at dbus-sysdeps.c:93
# 4  0xb74cf0ac in _dbus_warn_check_failed (
    format=0xb74df6b8 "arguments to %s() were incorrect, assertion \"%s\" failed in file %s line %d.\nThis is normally a bug in some application using the D-Bus library.\n") at dbus-internals.c:281
# 5  0xb74cf87b in _dbus_warn_return_if_fail (function=0xb74de5c0 <__func__.4821> "dbus_message_new_method_call", 
    assertion=0xb74dab26 "path != NULL", file=0xb74ddbc1 "dbus-message.c", line=1362) at dbus-internals.c:936
# 6  0xb74be1a7 in dbus_message_new_method_call (destination=0xb7f20bb4 <IBUS_SERVICE> "org.freedesktop.IBus", path=0x0, 
    iface=0xb7f20b60 <IBUS_INPUT_INTERFACE> "org.freedesktop.IBus.InputContext", method=0xb7f20ac3 "FocusOut") at dbus-message.c:1367
# 7  0xb7efc3f4 in SDL_DBus_CallVoidMethodInternal () from /usr/lib/libSDL2-2.0.so.0
# 8  0xb7efcc64 in SDL_DBus_CallVoidMethodOnConnection () from /usr/lib/libSDL2-2.0.so.0
# 9  0xb7efdeb5 in IBus_SimpleMessage () from /usr/lib/libSDL2-2.0.so.0
# 10 0xb7efda6b in IBus_SetupConnection () from /usr/lib/libSDL2-2.0.so.0
# 11 0xb7efdbd9 in SDL_IBus_Init () from /usr/lib/libSDL2-2.0.so.0
# 12 0xb7efcffe in SDL_IME_Init () from /usr/lib/libSDL2-2.0.so.0
# 13 0xb7ee7b75 in X11_InitKeyboard () from /usr/lib/libSDL2-2.0.so.0
# 14 0xb7eeec34 in X11_VideoInit () from /usr/lib/libSDL2-2.0.so.0
# 15 0xb7ed45d6 in SDL_VideoInit_REAL () from /usr/lib/libSDL2-2.0.so.0
# 16 0xb7e42be2 in SDL_InitSubSystem_REAL () from /usr/lib/libSDL2-2.0.so.0
# 17 0x0079cc9b in dr_os_init(int const*) ()
# 18 0x00711e68 in simu_main(int, char**) ()
---Type <return> to continue, or q <return> to quit---
# 19 0x0072b07b in sysmain(int, char**) ()
# 20 0x0041e127 in main ()
(gdb) 

So workaround is to start program with some misleading ibus setting, such as:

IBUS_ADDRESS=bääää /usr/bin/simutrans

This will let return SDL_IBus_Init with SDL_FALSE and game’s working.

I suggest to either make SDL more robust against such errors or to publicly document IBUS_ADDRESS parameter (e.g. like this: https://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlenvvars.html).

Remark: I posted this on mailing list and on https://discourse.libsdl.org/t/sdl-crashes-when-accessing-ibus-with-workaround/24713 but then discovered you wanted an entry in bugzilla. So this is kind-of duplicate.

On 2018-07-17 16:00:35 +0000, Sam Lantinga wrote:

Ryan, is this fixed with your recent change?

On 2018-11-03 22:17:03 +0000, Stas Sergeev wrote:

I have the same problem.
The bug is that when "CreateInputContext" method
fails, SDL continues with IBus, hitting an assert.
Something like this should fix the problem (untested):

--- SDL_ibus.c.old	2018-11-04 01:12:50.074897655 +0300
+++ SDL_ibus.c	2018-11-04 01:14:58.376753098 +0300
@@ -342,6 +342,8 @@
         dbus->connection_try_register_object_path(ibus_conn, input_ctx_path, &ibus_vtable, dbus, NULL);
         dbus->connection_flush(ibus_conn);
         result = SDL_TRUE;
+    } else {
+        return SDL_FALSE;
     }
 
     SDL_IBus_SetFocus(SDL_GetKeyboardFocus() != NULL);

On 2018-11-05 11:11:03 +0000, Ozkan Sezer wrote:

(In reply to Stas Sergeev from comment # 2)

I have the same problem.
The bug is that when "CreateInputContext" method
fails, SDL continues with IBus, hitting an assert.
Something like this should fix the problem (untested):

--- SDL_ibus.c.old	2018-11-04 01:12:50.074897655 +0300
+++ SDL_ibus.c	2018-11-04 01:14:58.376753098 +0300
@@ -342,6 +342,8 @@
         dbus->connection_try_register_object_path(ibus_conn, input_ctx_path, &ibus_vtable, dbus, NULL);
         dbus->connection_flush(ibus_conn);
         result = SDL_TRUE;
+    } else {
+        return SDL_FALSE;
     }
 
     SDL_IBus_SetFocus(SDL_GetKeyboardFocus() != NULL);

Do we not need to do dbus->connection_close(ibus_conn) and
dbus->connection_unref(ibus_conn) before returning SDL_FALSE
in there?

On 2018-11-05 11:33:04 +0000, Stas Sergeev wrote:

(In reply to Ozkan Sezer from comment # 3)

Do we not need to do dbus->connection_close(ibus_conn) and
dbus->connection_unref(ibus_conn) before returning SDL_FALSE
in there?
Likely so, ideed.
For me the problem happens only on a multilib
setup, the native one works properly. So I have
not built the multilib version of SDL with the
patch. It would be better if you attach the patch
with your amendments, and hope someone will test. :)

On 2018-11-05 11:44:37 +0000, Ozkan Sezer wrote:

Well I only looked at the code briefly and made that comment:
I do not have the issue myself so I cannot reproduce or test.
(If only we had a foolproof reproducer for this.)

On 2018-11-05 12:12:14 +0000, Stas Sergeev wrote:

(In reply to Ozkan Sezer from comment # 5)

(If only we had a foolproof reproducer for this.)
Easily: just modify the IBus_SetupConnection() the
way to not call SDL_DBus_CallMethodOnConnection(),
pretending it returned FALSE. Then you go further
but with "input_ctx_path == NULL", which will quickly
lead to an assert (right on SDL_IBus_SetFocus(), which
is even called in the same function).

@sezero
Copy link
Collaborator

@sezero sezero commented Mar 25, 2021

Is this still an issue?

Loading

@sezero sezero added this to the 2.0.16 milestone Mar 25, 2021
@icculus
Copy link
Collaborator

@icculus icculus commented Apr 4, 2021

Is this still an issue?

I don't know, but I'm about to throw a NULL check in there that will settle it for sure.

Loading

@icculus icculus closed this in 4914199 Apr 4, 2021
FtZPetruska added a commit to FtZPetruska/SDL that referenced this issue Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants