After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 668590 - Need to check result of g_bus_get()
Need to check result of g_bus_get()
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Mir
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2012-01-24 15:43 UTC by David Zeuthen (not reading bugmail)
Modified: 2017-12-08 09:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
mir: Fix potential use of NULL GDBusConnection (1.54 KB, patch)
2017-11-17 10:38 UTC, Philip Withnall
committed Details | Review

Description David Zeuthen (not reading bugmail) 2012-01-24 15:43:54 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

Thread 1 (Thread 0x7ffff7fd3980 (LWP 13801))

  • #0 g_logv
    at gmessages.h line 101
  • #1 g_log
    at gmessages.c line 792
  • #2 g_return_if_fail_warning
  • #3 g_dbus_connection_register_object
    at gdbusconnection.c line 4963
  • #4 g_dbus_connection_export_menu_model
    at gmenuexporter.c line 761
  • #5 gtk_application_x11_publish_menu
    at gtkapplication.c line 206
  • #6 gtk_application_set_app_menu_x11
    at gtkapplication.c line 222
  • #7 gtk_application_set_app_menu
    at gtkapplication.c line 1062
  • #8 gdu_application_startup
    at gduapplication.c line 172
  • #9 g_closure_invoke
    at gclosure.c line 774
  • #10 signal_emit_unlocked_R
    at gsignal.c line 3232
  • #11 g_signal_emit_valist
    at gsignal.c line 3033
  • #12 g_signal_emit
    at gsignal.c line 3090
  • #13 g_application_register
    at gapplication.c line 1202
  • #14 g_application_real_local_command_line
    at gapplication.c line 442
  • #15 gdu_application_local_command_line
    at gduapplication.c line 74
  • #16 g_application_run
    at gapplication.c line 1449
  • #17 main
    at main.c line 35

Comment 1 David Zeuthen (not reading bugmail) 2012-01-24 15:59:19 UTC
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'
Comment 2 Philip Withnall 2017-11-17 10:38:25 UTC
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>
Comment 3 Philip Withnall 2017-11-17 10:38:55 UTC
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.
Comment 4 Matthias Clasen 2017-12-08 01:54:19 UTC
Review of attachment 363908 [details] [review]:

looks fine
Comment 5 Philip Withnall 2017-12-08 09:55:47 UTC
Attachment 363908 [details] pushed as 276c462 - mir: Fix potential use of NULL GDBusConnection