dbusmenu assumes GDBus cancellation is reliable (and it's not)

Bug #953562 reported by Tony C.
630
This bug affects 97 people
Affects Status Importance Assigned to Milestone
GLib
Fix Released
Medium
glib2.0 (Ubuntu)
Fix Released
High
Allison Karlitskaya
libdbusmenu (Ubuntu)
Invalid
High
Unassigned

Bug Description

Was removing an item from the launcher when this error popped up

ProblemType: Crash
DistroRelease: Ubuntu 12.04
Package: indicator-appmenu 0.3.92-0ubuntu1
ProcVersionSignature: Ubuntu 3.2.0-18.29-generic 3.2.9
Uname: Linux 3.2.0-18-generic x86_64
NonfreeKernelModules: nvidia
ApportVersion: 1.94.1-0ubuntu2
Architecture: amd64
Date: Mon Mar 12 19:55:19 2012
ExecutablePath: /usr/lib/indicator-appmenu/hud-service
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Alpha amd64 (20120309)
ProcCmdline: /usr/lib/indicator-appmenu/hud-service
ProcEnviron:
 SHELL=/bin/bash
 PATH=(custom, user)
 LANG=en_US.UTF-8
SegvAnalysis:
 Segfault happened at: 0x7fb5ae7411a9: mov 0x30(%rbx),%rdi
 PC (0x7fb5ae7411a9) ok
 source "0x30(%rbx)" (0xaaaaaaaaaaaaaada) not located in a known VMA region (needed readable region)!
 destination "%rdi" ok
SegvReason: reading unknown VMA
Signal: 11
SourcePackage: indicator-appmenu
StacktraceTop:
 ?? () from /usr/lib/x86_64-linux-gnu/libdbusmenu-glib.so.4
 g_simple_async_result_complete () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
 ?? () from /usr/lib/x86_64-linux-gnu/libgio-2.0.so.0
 g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
 ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
Title: hud-service crashed with SIGSEGV in g_simple_async_result_complete()
UpgradeStatus: Upgraded to precise on 2012-03-12 (0 days ago)
UserGroups: adm audio cdrom dip lpadmin plugdev sambashare sudo

Related branches

Revision history for this message
Tony C. (tonyc-atl-ga) wrote :
Revision history for this message
Apport retracing service (apport) wrote :

StacktraceTop:
 menuproxy_build_cb (object=<optimized out>, res=<optimized out>, user_data=0x19bfee0) at /build/buildd/libdbusmenu-0.5.94/./libdbusmenu-glib/client.c:1071
 g_simple_async_result_complete (simple=0x19d1060) at /build/buildd/glib2.0-2.31.20/./gio/gsimpleasyncresult.c:744
 complete_in_idle_cb (data=0x19d1060) at /build/buildd/glib2.0-2.31.20/./gio/gsimpleasyncresult.c:756
 g_main_dispatch (context=0x191de40) at /build/buildd/glib2.0-2.31.20/./glib/gmain.c:2510
 g_main_context_dispatch (context=0x191de40) at /build/buildd/glib2.0-2.31.20/./glib/gmain.c:3047

Revision history for this message
Apport retracing service (apport) wrote : Stacktrace.txt
Revision history for this message
Apport retracing service (apport) wrote : ThreadStacktrace.txt
Changed in indicator-appmenu (Ubuntu):
importance: Undecided → Medium
summary: - hud-service crashed with SIGSEGV in g_simple_async_result_complete()
+ hud-service crashed with SIGSEGV in menuproxy_build_cb()
tags: removed: need-amd64-retrace
Revision history for this message
Launchpad Janitor (janitor) wrote : Re: hud-service crashed with SIGSEGV in menuproxy_build_cb()

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in indicator-appmenu (Ubuntu):
status: New → Confirmed
visibility: private → public
Changed in indicator-appmenu (Ubuntu):
importance: Medium → High
assignee: nobody → Ryan Lortie (desrt)
tags: added: apport-request-retrace
Revision history for this message
Allison Karlitskaya (desrt) wrote :

This looks like a dbusmenu bug. dbusmenu does this call:

                        g_dbus_proxy_new(priv->session_bus,
                                         G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START,
                                         dbusmenu_interface_info,
                                         priv->dbus_name,
                                         priv->dbus_object,
                                         DBUSMENU_INTERFACE,
                                         priv->menuproxy_cancel,
                                         menuproxy_build_cb,
                                         client);

and makes no assurances that 'client' will continue to be around long enough to receive the results. If 'client' gets freed before then the call to menuproxy_build_cb() will crash.

Revision history for this message
Allison Karlitskaya (desrt) wrote :

That said, there is this code on the other side:

        /* NOTE: We're not using any other variables before checking
           the result because they could be destroyed and thus invalid */
        GDBusProxy * proxy = g_dbus_proxy_new_finish(res, &error);
        if (error != NULL) {
                g_warning("Unable to get menu proxy: %s", error->message);
                g_error_free(error);
                return;
        }

        /* If this wasn't cancelled, we should be good */
        DbusmenuClient * client = DBUSMENU_CLIENT(user_data);

so even though the client may not be around, the callback should return before attempting to deal with the client.

The cancellable is cancelled from the dispose().

It seems that it is not possible for multiple concurrent calls to get stacked (ie: and the cancellable overwritten with a new one) because of this check:

                /* Check to see if we're already building one */
                if (priv->menuproxy_cancel == NULL) {
                        priv->menuproxy_cancel = g_cancellable_new();

                        g_dbus_proxy_new(priv->session_bus,

Revision history for this message
Apport retracing service (apport) wrote : Updated stack trace from duplicate bug 954158

Package: indicator-appmenu 0.3.92-0ubuntu1
ProcCmdline: /usr/lib/indicator-appmenu/hud-service

Revision history for this message
Apport retracing service (apport) wrote : Dependencies.txt
Revision history for this message
Apport retracing service (apport) wrote : ProcMaps.txt
Revision history for this message
Apport retracing service (apport) wrote : Stacktrace.txt
Revision history for this message
Apport retracing service (apport) wrote : ThreadStacktrace.txt
tags: removed: apport-request-retrace
Revision history for this message
Allison Karlitskaya (desrt) wrote : Re: hud-service crashed with SIGSEGV in menuproxy_build_cb()

After a bit more research the problem is clear: GDBus makes no guarantees that cancelling a cancellable will result in the associated async operation terminating in an error. Specifically: if the (successful) result is already sent to the main context as an idle and waiting for dispatch then cancel() at this time will not be enough to fail it.

Talking to David and Alex about if GIO should make this guarantee or if we need to fix dbusmenu...

Revision history for this message
Allison Karlitskaya (desrt) wrote :
summary: - hud-service crashed with SIGSEGV in menuproxy_build_cb()
+ dbusmenu assumes GDBus cancellation is reliable (and it's not)
affects: indicator-appmenu (Ubuntu) → libdbusmenu (Ubuntu)
affects: libdbusmenu (Ubuntu) → glib2.0 (Ubuntu)
Changed in glib2.0 (Ubuntu):
status: Confirmed → Fix Committed
Changed in libdbusmenu (Ubuntu):
importance: Undecided → High
status: New → Invalid
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package glib2.0 - 2.31.20-0ubuntu3

---------------
glib2.0 (2.31.20-0ubuntu3) precise; urgency=low

  * debian/patches/bugzilla_gdbus_use_reliable_cancellation.patch,
    debian/patches/bugzilla_reliable_cancellable.patch:
    - patches from GNOME bug #672013, should make gdbus cancellation
      reliable and fix dbusmenu lp: #953562
  * debian/libglib2.0-0.symbols:
    - updated for the new symbol
 -- Sebastien Bacher <email address hidden> Wed, 14 Mar 2012 11:45:37 +0100

Changed in glib2.0 (Ubuntu):
status: Fix Committed → Fix Released
Changed in glib:
importance: Unknown → Medium
status: Unknown → Confirmed
Changed in glib:
status: Confirmed → Fix Released
To post a comment you must log in.