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 3854

Summary: arguments to dbus_type_is_basic() were incorrect
Product: SDL Reporter: Aaron <aaronbpaden>
Component: *don't know*Assignee: Ryan C. Gordon <icculus>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: blocker    
Priority: P2 CC: lgblgblgb, s.jegen, sezeroz
Version: 2.0.6   
Hardware: x86_64   
OS: Linux   

Description Aaron 2017-09-29 12:56:54 UTC
As of 2.0.6, all of my games are failing with the following error:

process 31778: arguments to dbus_type_is_basic() were incorrect, assertion "dbus_type_is_valid (typecode) || typecode == DBUS_TYPE_INVALID" failed in file dbus-signature.c line 322.
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


This can be worked around by compiling with --disable-dbus.
Comment 1 Ozkan Sezer 2017-09-29 18:47:14 UTC
Reproduced this on Fedora 20 / x86_64: running the checkkeys test
against a newly built SDL2 fails:
$ LD_LIBRARY_PATH=$HOME/opt/SDL2/lib ./checkkeys
process 12645: arguments to dbus_type_is_basic() were incorrect, assertion "dbus_type_is_valid (typecode) || typecode == DBUS_TYPE_INVALID" failed in file dbus-signature.c line 322.
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
Aborted (core dumped)
Comment 2 Ozkan Sezer 2017-09-29 19:52:21 UTC
The issue seems to have started with changeset 11042
by Ryan:  https://hg.libsdl.org/SDL/rev/303c875e47f0

Rev. 11041 does not have this issue.
Comment 3 Ozkan Sezer 2017-09-30 11:45:45 UTC
This issue has been reported to RedHat/Fedora, too :
https://bugzilla.redhat.com/show_bug.cgi?id=1496895
Comment 4 Sam Lantinga 2017-09-30 17:01:24 UTC
Ryan, this is a critical bug affecting Steam as well. Can you fix ASAP?

Thanks!
Comment 5 Silvan 2017-10-01 12:53:14 UTC
I can confirm this issue on Arch Linux as well. Please find a stacktrace below.

process 3729: arguments to dbus_type_is_basic() were incorrect, assertion "dbus_type_is_valid (typecode) || typecode == DBUS_TYPE_INVALID" failed in file dbus-signature.c line 322.
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.
0x00007ffff77088a0 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff77088a0 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7709f09 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff495d8a7 in ?? () from /usr/lib/libdbus-1.so.3
#3  0x00007ffff49543e7 in _dbus_warn_check_failed () from /usr/lib/libdbus-1.so.3
#4  0x00007ffff494f4ed in dbus_type_is_basic () from /usr/lib/libdbus-1.so.3
#5  0x00007ffff4946863 in dbus_message_append_args_valist () from /usr/lib/libdbus-1.so.3
#6  0x00007ffff7b8414c in SDL_DBus_CallVoidMethodInternal (ap=0x7fffffffd870, method=0x55555578bb40 "\001",
    interface=0x7ffff7ba5c80 <IBUS_INPUT_INTERFACE> "org.freedesktop.IBus.InputContext", path=<optimized out>,
    node=0x7ffff7ba5cf0 <IBUS_SERVICE> "org.freedesktop.IBus", conn=0x55555578ff70) at /home/silvan/build/SDL2-2.0.6/src/core/linux/SDL_dbus.c:220
#7  SDL_DBus_CallVoidMethodOnConnection (conn=0x55555578ff70, node=node@entry=0x7ffff7ba5cf0 <IBUS_SERVICE> "org.freedesktop.IBus", path=<optimized out>,
    interface=interface@entry=0x7ffff7ba5c80 <IBUS_INPUT_INTERFACE> "org.freedesktop.IBus.InputContext", method=method@entry=0x7ffff7ba5baf "FocusOut")
    at /home/silvan/build/SDL2-2.0.6/src/core/linux/SDL_dbus.c:240
#8  0x00007ffff7b851c6 in IBus_SimpleMessage (method=0x7ffff7ba5baf "FocusOut") at /home/silvan/build/SDL2-2.0.6/src/core/linux/SDL_ibus.c:482
#9  SDL_IBus_SetFocus (focused=<optimized out>) at /home/silvan/build/SDL2-2.0.6/src/core/linux/SDL_ibus.c:490
#10 IBus_SetupConnection (dbus=dbus@entry=0x7ffff7dd7480 <dbus>,
    addr=addr@entry=0x55555578bcb0 "unix:abstract=/tmp/dbus-OWLLq6hr,guid=ccac163e8d8b220cedc3577559d09fe4")
    at /home/silvan/build/SDL2-2.0.6/src/core/linux/SDL_ibus.c:346
#11 0x00007ffff7b852f4 in SDL_IBus_Init () at /home/silvan/build/SDL2-2.0.6/src/core/linux/SDL_ibus.c:436
#12 0x00007ffff7b84836 in SDL_IME_Init () at /home/silvan/build/SDL2-2.0.6/src/core/linux/SDL_ime.c:91
#13 0x00007ffff7b6f11a in X11_InitKeyboard (_this=_this@entry=0x555555759660) at /home/silvan/build/SDL2-2.0.6/src/video/x11/SDL_x11keyboard.c:410
#14 0x00007ffff7b7710c in X11_VideoInit (_this=0x555555759660) at /home/silvan/build/SDL2-2.0.6/src/video/x11/SDL_x11video.c:446
#15 0x00007ffff7b618e3 in SDL_VideoInit_REAL (driver_name=<optimized out>, driver_name@entry=0x0) at /home/silvan/build/SDL2-2.0.6/src/video/SDL_video.c:532
#16 0x00007ffff7aa50d7 in SDL_InitSubSystem_REAL (flags=16928) at /home/silvan/build/SDL2-2.0.6/src/SDL.c:170
#17 SDL_Init_REAL (flags=<optimized out>) at /home/silvan/build/SDL2-2.0.6/src/SDL.c:241
#18 0x0000555555555350 in main (argc=<optimized out>, argv=0x7fffffffe5f8) at testjoystick.c:252

This line is most likely the culprit.

            if ((firstarg == DBUS_TYPE_INVALID) || dbus.message_append_args_valist(msg, firstarg, ap)) {

it looks like there would be an invalid type passed to dbus.message_append_args_valist.
Comment 6 Ozkan Sezer 2017-10-01 13:24:01 UTC
IBus_SimpleMessage() doesn't pass any vargars to SDL_DBus_CallVoidMethodOnConnection()
therefore it receives garbage I guess.
Comment 7 Ozkan Sezer 2017-10-01 13:36:15 UTC
The following patch fixes it for me: please review.

diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c
--- a/src/core/linux/SDL_ibus.c
+++ b/src/core/linux/SDL_ibus.c
@@ -479,7 +479,7 @@ IBus_SimpleMessage(const char *method)
     SDL_DBusContext *dbus = SDL_DBus_GetContext();
     
     if (IBus_CheckConnection(dbus)) {
-        SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, method);
+        SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE, input_ctx_path, IBUS_INPUT_INTERFACE, method, DBUS_TYPE_INVALID);
     }
 }
Comment 8 Silvan 2017-10-01 15:07:02 UTC
(In reply to Ozkan Sezer from comment #7)
> The following patch fixes it for me: please review.
>
> diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c
> --- a/src/core/linux/SDL_ibus.c
> +++ b/src/core/linux/SDL_ibus.c
> @@ -479,7 +479,7 @@ IBus_SimpleMessage(const char *method)
>      SDL_DBusContext *dbus = SDL_DBus_GetContext();
>      
>      if (IBus_CheckConnection(dbus)) {
> -        SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE,
> input_ctx_path, IBUS_INPUT_INTERFACE, method);
> +        SDL_DBus_CallVoidMethodOnConnection(ibus_conn, IBUS_SERVICE,
> input_ctx_path, IBUS_INPUT_INTERFACE, method, DBUS_TYPE_INVALID);
>      }
>  }

I can confirm that this fixes the issue for me as well.

To me it looks like this would be the correct way to call SDL_DBus_CallVoidMethodOnConnection with no further arguments but somebody who is more familiar with that code should do a proper review.
Comment 9 Ozkan Sezer 2017-10-05 07:13:56 UTC
PING?
Comment 10 Sam Lantinga 2017-10-05 16:37:49 UTC
Fixed, thanks!
https://hg.libsdl.org/SDL/rev/dc7245e3d1f2
Comment 11 Sam Lantinga 2017-10-05 16:38:00 UTC
Marking fixed
Comment 12 Ryan C. Gordon 2017-10-07 02:06:46 UTC
*** Bug 3863 has been marked as a duplicate of this bug. ***