GNOME Bugzilla – Bug 668590
Need to check result of g_bus_get()
Last modified: 2017-12-08 09:55:52 UTC
g_bus_get() may return NULL in certain corner-cases and we need to handle that properly <davidz> oh, hah, and if you manually kill the root-owned session bus <davidz> then I get a boatload of <davidz> GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion `G_IS_DBUS_CONNECTION (connection)' failed <davidz> because the address in lingering in an X property <davidz> but we failed to connect <davidz> but someone is not checking the result from g_bus_get() <davidz> would be good to check that we DTRT in all these edge cases <davidz> to avoid bug-report inflow Here's a backtrace [davidz@lucifer palimpsest]$ sudo G_DEBUG=fatal-warnings gdb ./palimpsest GNU gdb (GDB) Fedora (7.4.50.20120120-10.fc17) Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /home/davidz/Hacking/gnome-disk-utility/src/palimpsest/palimpsest...done. (gdb) run Starting program: /home/davidz/Hacking/gnome-disk-utility/src/palimpsest/palimpsest [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Detaching after fork from child process 13804. Detaching after fork from child process 13805. GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion `G_IS_DBUS_CONNECTION (connection)' failed Program received signal SIGTRAP, Trace/breakpoint trap. g_logv (log_domain=0x3da48f6641 "GLib-GIO", log_level=G_LOG_LEVEL_CRITICAL, format=0x3da30b62da "%s: assertion `%s' failed", args1=args1@entry=0x7fffffffdc48) at gmessages.h:101 101 void g_logv (const gchar *log_domain, Missing separate debuginfos, use: debuginfo-install adwaita-gtk3-theme-3.3.4-1.fc17.x86_64 dbus-libs-1.4.10-4.fc17.x86_64 expat-2.0.1-12.fc17.x86_64 gvfs-1.11.3-0.1.20120120.fc17.x86_64 libXau-1.0.6-3.fc17.x86_64 libXrender-0.9.6-3.fc17.x86_64 libbluray-0.2.1-1.fc17.x86_64 libcanberra-0.28-5.fc17.x86_64 libcanberra-gtk3-0.28-5.fc17.x86_64 libcroco-0.6.3-2.fc17.x86_64 libffi-3.0.10-2.fc17.x86_64 libogg-1.2.2-4.fc17.x86_64 libpng-1.5.7-2.fc17.x86_64 librsvg2-2.35.1-2.fc17.x86_64 libselinux-2.1.9-2.fc17.x86_64 libtdb-1.2.9-14.fc17.x86_64 libtool-ltdl-2.4.2-3.fc17.x86_64 libvorbis-1.3.2-2.fc17.x86_64 libxcb-1.8-2.fc17.x86_64 libxml2-2.7.8-7.fc17.x86_64 nss-softokn-freebl-3.13.1-17.fc17.x86_64 pixman-0.24.2-1.fc17.x86_64 zlib-1.2.5-6.fc17.x86_64 (gdb) t a a bt
+ Trace 229509
Thread 1 (Thread 0x7ffff7fd3980 (LWP 13801))
Also, if running with G_DBUS_DEBUG=all then I get this output just before the first GLib-GIO-CRITICAL: GDBus-debug:Address: In g_dbus_address_get_for_bus_sync() for bus type `session' GDBus-debug:Address: env var DBUS_SESSION_BUS_ADDRESS is not set GDBus-debug:Address: env var DBUS_SYSTEM_BUS_ADDRESS is not set GDBus-debug:Address: env var DBUS_STARTER_BUS_TYPE is not set GDBus-debug:Address: Running `dbus-launch --autolaunch=ca4eb76de69798995f25d61700000012 --binary-syntax --close-stderr' to get bus address (possibly autolaunching) Detaching after fork from child process 14040. GDBus-debug:Address: dbus-launch output: 0000: 75 6e 69 78 3a 61 62 73 74 72 61 63 74 3d 2f 74 unix:abstract=/t 0010: 6d 70 2f 64 62 75 73 2d 56 64 70 46 55 42 38 4f mp/dbus-VdpFUB8O 0020: 4f 41 2c 67 75 69 64 3d 38 36 61 37 63 36 36 66 OA,guid=86a7c66f 0030: 62 64 38 61 31 35 63 63 37 37 62 62 61 32 34 33 bd8a15cc77bba243 0040: 30 30 30 30 31 39 62 37 00 64 0e 00 00 01 00 80 000019b7.d...... 0050: 04 00 00 00 00 ..... GDBus-debug:Address: dbus-launch stderr output: 14040: Autolaunch enabled (using X11). 14040: --exit-with-session automatically enabled 14040: Connected to X11 display ':0' 14040: dbus-daemon is already running. Returning existing parameters. 14040: dbus-launch exiting GDBus-debug:Address: Returning address `unix:abstract=/tmp/dbus-VdpFUB8OOA,guid=86a7c66fbd8a15cc77bba243000019b7' for bus type `session' GDBus-debug:Address: In g_dbus_address_get_for_bus_sync() for bus type `session' GDBus-debug:Address: env var DBUS_SESSION_BUS_ADDRESS is not set GDBus-debug:Address: env var DBUS_SYSTEM_BUS_ADDRESS is not set GDBus-debug:Address: env var DBUS_STARTER_BUS_TYPE is not set GDBus-debug:Address: Running `dbus-launch --autolaunch=ca4eb76de69798995f25d61700000012 --binary-syntax --close-stderr' to get bus address (possibly autolaunching) Detaching after fork from child process 14041. GDBus-debug:Address: dbus-launch output: 0000: 75 6e 69 78 3a 61 62 73 74 72 61 63 74 3d 2f 74 unix:abstract=/t 0010: 6d 70 2f 64 62 75 73 2d 56 64 70 46 55 42 38 4f mp/dbus-VdpFUB8O 0020: 4f 41 2c 67 75 69 64 3d 38 36 61 37 63 36 36 66 OA,guid=86a7c66f 0030: 62 64 38 61 31 35 63 63 37 37 62 62 61 32 34 33 bd8a15cc77bba243 0040: 30 30 30 30 31 39 62 37 00 64 0e 00 00 01 00 80 000019b7.d...... 0050: 04 00 00 00 00 ..... GDBus-debug:Address: dbus-launch stderr output: 14041: Autolaunch enabled (using X11). 14041: --exit-with-session automatically enabled 14041: Connected to X11 display ':0' 14041: dbus-daemon is already running. Returning existing parameters. 14041: dbus-launch exiting GDBus-debug:Address: Returning address `unix:abstract=/tmp/dbus-VdpFUB8OOA,guid=86a7c66fbd8a15cc77bba243000019b7' for bus type `session'
Created attachment 363908 [details] [review] mir: Fix potential use of NULL GDBusConnection If we fail to connect to the session bus, it would be a bit silly to immediately try and use that NULL connection. Signed-off-by: Philip Withnall <withnall@endlessm.com>
I’ve audited the results of `git grep g_bus_get` in GLib and GTK+, and found one instance where a NULL/error return value from it is ignored: gdk/mir/gdkmirdisplay.c in GTK+. Reassigning.
Review of attachment 363908 [details] [review]: looks fine
Attachment 363908 [details] pushed as 276c462 - mir: Fix potential use of NULL GDBusConnection