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 598339 - segfault in gpm_disks_register() on error == NULL
segfault in gpm_disks_register() on error == NULL
Status: RESOLVED FIXED
Product: gnome-power-manager
Classification: Deprecated
Component: gnome-power-manager
2.28.x
Other Linux
: Normal major
: ---
Assigned To: GNOME Power Manager Maintainer(s)
GNOME Power Manager Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2009-10-13 21:37 UTC by Martin Pitt
Modified: 2009-10-14 07:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
fix error messages/comments (1.09 KB, patch)
2009-10-13 21:41 UTC, Martin Pitt
none Details | Review
fix crash (1.28 KB, patch)
2009-10-13 21:44 UTC, Martin Pitt
none Details | Review
git formatted patch (1.33 KB, patch)
2009-10-13 22:31 UTC, Martin Pitt
none Details | Review

Description Martin Pitt 2009-10-13 21:37:43 UTC
Recently, we started to get lots of crash reports (https://launchpad.net/bugs/431023) about gpm segfaulting when pulling the AC plug:

  • #0 gpm_disks_set_spindown_timeout
    at gpm-disks.c line 101
  • #1 gpm_manager_client_changed_cb

This shows that it's crashing in gpm_disks_register() in

-------------- 8< -------------
        /* set spindown timeouts */
        ret = dbus_g_proxy_call (disks->priv->proxy, "DriveSetAllSpindownTimeouts", &error,
                                 G_TYPE_INT, timeout,
                                 G_TYPE_STRV, options,
                                 G_TYPE_INVALID,
                                 G_TYPE_STRING, disks->priv->cookie,
                                 G_TYPE_INVALID);
        if (!ret) {
                egg_warning ("failed to set spindown timeout: %s", error->message);
-------------- 8< -------------
in the last line, on a NULL pointer access (as apport figured out from the disassembly/registers). The only plausible cause for this is that dbus_g_proxy_call() returned FALSE without setting error. According to [1] this isn't supposed to happen, so there might be an underlying bug in dbus-glib.

For robustness, would you consider explicitly checking for NULL there? (I'll attach a patch in a minute)

[1] http://library.gnome.org/devel/dbus-glib/unstable/dbus-glib-DBusGProxy.html#dbus-g-proxy-call
Comment 1 Martin Pitt 2009-10-13 21:41:13 UTC
Created attachment 145381 [details] [review]
fix error messages/comments

While fixing that, I noticed that the error messages/comments in gpm-disks.c were wrong; it's actually talking to DK-disks, not DK-power. Attaching git formatted patch for "git am" love.
Comment 2 Martin Pitt 2009-10-13 21:44:51 UTC
Created attachment 145382 [details] [review]
fix crash
Comment 3 Martin Pitt 2009-10-13 22:12:43 UTC
Chris Coulson pointed out that bug 23617 is a likely cause for this condition; it's a code path in dbus-glib which returns FALSE/error=NULL on a demarshalling error.
Comment 4 Matthias Clasen 2009-10-13 22:20:02 UTC
As Chris Coulson spotted, the actual bug is the missing indirection in the return value. It should be &disks->priv->cookie.
Comment 5 Martin Pitt 2009-10-13 22:25:26 UTC
Sorry, that was a bug in the fd.o bug tracker: http://bugs.freedesktop.org/show_bug.cgi?id=23617
Comment 6 Chris Coulson 2009-10-13 22:26:19 UTC
Heh, I was just about to comment there but got a collision :)
Comment 7 Martin Pitt 2009-10-13 22:31:48 UTC
Created attachment 145385 [details] [review]
git formatted patch

Chris' change in git formatted patch version.
Comment 8 Martin Pitt 2009-10-13 22:39:15 UTC
Comment on attachment 145385 [details] [review]
git formatted patch

Whoops, no need to change the one in unregister.
Comment 9 Chris Coulson 2009-10-13 22:59:06 UTC
I've committed the change now (only in gpm_disks_register). I can't change the status of this bug to fixed though ;)
Comment 10 Martin Pitt 2009-10-14 07:49:43 UTC
Chris, thanks! Chris, Richard, can you please also apply my first patch ("fix error messages/comments")?
Comment 11 Richard Hughes 2009-10-14 07:56:11 UTC
(In reply to comment #4)
> As Chris Coulson spotted, the actual bug is the missing indirection in the
> return value. It should be &disks->priv->cookie.

Excellent, thanks.

(In reply to comment #10)
> Chris, thanks! Chris, Richard, can you please also apply my first patch ("fix
> error messages/comments")?

Applied, thanks.

I've also marked this bug as fixed. I've been unwell for the last couple of days, and it was nice to come back to a nicely fixed bug like this. Thanks guys!