bus1 / dbus-broker

Linux D-Bus Message Broker
https://github.com/bus1/dbus-broker/wiki
Apache License 2.0
675 stars 78 forks source link

Duplicate monitoring match expressions crashes entire GNOME session #260

Closed dbazile closed 3 years ago

dbazile commented 3 years ago

If I use a specific duplicate dbus monitoring match expressions, the entire GNOME session is killed as soon as I exit the script, kicking me out to the login screen. At one point during testing last night it even locked up the system and I had to do a hard power off/on to get back in.

It took a while to narrow down what specifically was causing the crash but I found that if there is a duplicate match that contains a sender=... clause, I can consistently reproduce the crash.

I originally posted this at dbus/dbus-python but was redirected here.

It does look like this might be the same issue as #245 but my currently-installed dbus-broker is v27 which seems to have had the fix for #245 incorporated.

Versions

Fedora 33.

$ dnf list installed \*dbus\*
Installed Packages
abrt-dbus.x86_64                             2.14.5-1.fc33                            @updates
dbus.x86_64                                  1:1.12.20-2.fc33                         @fedora 
dbus-broker.x86_64                           27-2.fc33                                @updates
dbus-common.noarch                           1:1.12.20-2.fc33                         @fedora 
dbus-daemon.x86_64                           1:1.12.20-2.fc33                         @fedora 
dbus-glib.x86_64                             0.110-10.fc33                            @updates
dbus-libs.x86_64                             1:1.12.20-2.fc33                         @fedora 
dbus-tools.x86_64                            1:1.12.20-2.fc33                         @fedora 
dbus-x11.x86_64                              1:1.12.20-2.fc33                         @fedora 
dbusmenu-qt.x86_64                           0.9.3-0.25.20160218.fc33                 @fedora 
dleyna-connector-dbus.x86_64                 0.3.0-8.fc33                             @fedora 
libdbusmenu.x86_64                           16.04.0-16.fc33                          @fedora 
libdbusmenu-gtk3.x86_64                      16.04.0-16.fc33                          @fedora 
python3-dbus.x86_64                          1.2.16-3.fc33                            @fedora 
python3-slip-dbus.noarch                     0.6.4-21.fc33                            @fedora 
xdg-dbus-proxy.x86_64                        0.1.2-3.fc33                             @fedora

Steps to reproduce

  1. Run the following test script:
from dbus import SessionBus
from dbus.mainloop.glib import DBusGMainLoop
from gi.repository import GLib

DBusGMainLoop(set_as_default=True)
bus = SessionBus()

proxy = bus.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
proxy.BecomeMonitor([
    'type=method_call, interface=org.freedesktop.Notifications, member=Notify, sender=org.freedesktop.Notify',
    'type=method_call, interface=org.freedesktop.Notifications, member=Notify, sender=org.freedesktop.Notify',
], 0, dbus_interface='org.freedesktop.DBus.Monitoring')

bus.add_message_filter(lambda _, msg: print(msg))

loop = GLib.MainLoop()
try:
    loop.run()
except KeyboardInterrupt:
    loop.quit()
  1. Press Ctrl+C and GNOME should immediately crash

journalctl output

Feb 27 09:07:55 kefka dbus-broker-launch[29401]: dbus-broker: ../src/bus/match.c:1016: match_registry_deinit: Assertion `c_assert_result && "c_rbtree_is_empty(&registry->monitor_tree)"' failed.
Feb 27 09:07:55 kefka systemd-coredump[30608]: Process 29401 (dbus-broker) of user 1000 dumped core.

                                               Stack trace of thread 29401:
                                               #0  0x00007f7c873459d5 raise (libc.so.6 + 0x3d9d5)
                                               #1  0x00007f7c8732e8a4 abort (libc.so.6 + 0x268a4)
                                               #2  0x00007f7c8732e789 __assert_fail_base.cold (libc.so.6 + 0x26789)
                                               #3  0x00007f7c8733e026 __assert_fail (libc.so.6 + 0x36026)
                                               #4  0x00005653502ee248 name_free (dbus-broker + 0x12248)
                                               #5  0x00005653502ef7b1 driver_goodbye (dbus-broker + 0x137b1)
                                               #6  0x00005653502f604b peer_dispatch (dbus-broker + 0x1a04b)
                                               #7  0x00005653502e1f0a broker_run (dbus-broker + 0x5f0a)
                                               #8  0x00005653502e0743 main (dbus-broker + 0x4743)
                                               #9  0x00007f7c873301e2 __libc_start_main (libc.so.6 + 0x281e2)
                                               #10 0x00005653502e136e _start (dbus-broker + 0x536e)
Feb 27 09:07:55 kefka gvfsd[29829]: A connection to the bus can't be made
Feb 27 09:07:55 kefka gnome-software[29907]: lost session service
Feb 27 09:07:55 kefka gnome-session-binary[29452]: WARNING: Lost name on bus: org.gnome.SessionManager
Feb 27 09:07:55 kefka gnome-session[29452]: gnome-session-binary[29452]: WARNING: Lost name on bus: org.gnome.SessionManager
Feb 27 09:07:55 kefka gvfsd[29681]: A connection to the bus can't be made
Feb 27 09:07:55 kefka gnome-shell-calendar-server[29716]: gnome-shell-calendar-server[29716]: Lost (or failed to acquire) the name org.gnome.Shell.CalendarServer - exiting
Feb 27 09:07:55 kefka systemd[29370]: dbus-:1.25-org.a11y.atspi.Registry@0.service: Succeeded.
Feb 27 09:07:55 kefka dbus-broker-launch[29400]: ERROR launcher_run @ ../src/launch/launcher.c +1445: Return code 1
Feb 27 09:07:55 kefka dbus-broker-launch[29400]:       run @ ../src/launch/main.c +152
Feb 27 09:07:55 kefka systemd[29370]: app-gnome-org.gnome.SettingsDaemon.DiskUtilityNotify-29870.scope: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: dbus-:1.2-ca.desrt.dconf@0.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: gvfs-gphoto2-volume-monitor.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: gvfs-goa-volume-monitor.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: gvfs-mtp-volume-monitor.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: xdg-permission-store.service: Main process exited, code=exited, status=1/FAILURE
Feb 27 09:07:55 kefka systemd[29370]: xdg-permission-store.service: Failed with result 'exit-code'.
Feb 27 09:07:55 kefka systemd[29370]: gvfs-afc-volume-monitor.service: Succeeded.
Feb 27 09:07:55 kefka ibus-portal[30141]: Error releasing name org.freedesktop.portal.IBus: The connection is closed
Feb 27 09:07:55 kefka dbus-broker-launch[29400]: Caught SIGCHLD of broker.
Feb 27 09:07:55 kefka dbus-broker[29658]: Dispatched 408 messages @ 8(±35)μs / message.
Feb 27 09:07:55 kefka gnome-shell[29472]: Lost or failed to acquire name org.gnome.Mutter.ScreenCast
Feb 27 09:07:55 kefka gnome-shell[29472]: Lost or failed to acquire name org.gnome.Mutter.RemoteDesktop
Feb 27 09:07:55 kefka systemd[29370]: dbus-:1.2-org.gnome.Shell.CalendarServer@0.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: run-user-1000-gvfs.mount: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: dbus-:1.2-org.gnome.Identity@0.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: gvfs-udisks2-volume-monitor.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: at-spi-dbus-bus.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: dbus-:1.2-org.gnome.Shell.Notifications@0.service: Succeeded.
Feb 27 09:07:55 kefka systemd[29370]: gvfs-daemon.service: Succeeded.
Feb 27 09:07:55 kefka dbus-broker-launch[29400]:       main @ ../src/launch/main.c +178
Feb 27 09:07:55 kefka dbus-broker-launch[29400]: Exiting due to fatal error: -131
Feb 27 09:07:55 kefka systemd[29370]: dbus-broker.service: Main process exited, code=exited, status=1/FAILURE
dvdhrm commented 3 years ago

Thanks a lot for the highly detailed report! I now added a test-case for this and fixed the underlying issue in: 250529d15cc80fefaae57416e1108f692a424c24

I will prep a release sometime this week. If the issue remains with this fix (it will be part of the v28 release), please let me know!

Thanks a lot!

dbazile commented 3 years ago

Awesome, thanks! I've set a reminder to test this again and close this issue as soon as v28 makes its way into Fedora 33.

dbazile commented 3 years ago

dbus-broker v28 made it into Fedora 33's update stream a few days ago. Upgraded, tested and verified that the session crash is fixed. :+1:

dvdhrm commented 3 years ago

Cool, thanks a lot!