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 683533 - [PATCH] Crash in got_power_proxy_cb()
[PATCH] Crash in got_power_proxy_cb()
Status: RESOLVED FIXED
Product: gnome-control-center
Classification: Core
Component: Power
3.4.x
Other Linux
: Normal normal
: ---
Assigned To: Richard Hughes
Control-Center Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-09-06 20:15 UTC by Michael Terry
Modified: 2012-09-10 18:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (3.86 KB, patch)
2012-09-06 20:16 UTC, Michael Terry
accepted-commit_now Details | Review

Description Michael Terry 2012-09-06 20:15:43 UTC
Hello!  This is an Ubuntu bug that seems to also be a GNOME bug.
Downstream bug: https://bugs.launchpad.net/ubuntu/+source/gnome-control-center/+bug/929378
Stacktrace: https://launchpadlibrarian.net/92392207/Stacktrace.txt

In cc-power-panel.c, there is a cancellable object passed to various dbus operations calls.  But it isn't used well:

1) It is cancelled in finalize, after dispose has already NULL'd the pointer out.  So it never actually gets to cancel anything.

2) When cancelled, the callbacks registered with the cancellable object don't properly handle the case of the panel object being disposed and thus may attempt to set/access freed memory.

Here's a patch that attempts to fix both those issues.
Comment 1 Michael Terry 2012-09-06 20:16:29 UTC
Created attachment 223701 [details] [review]
Proposed patch
Comment 2 Bastien Nocera 2012-09-07 17:28:29 UTC
Review of attachment 223701 [details] [review]:

Otherwise looks good to apply to both gnome-3-4 and master.

::: panels/power/cc-power-panel.c
@@ +653,3 @@
+    {
+      g_error_free (error);
+      return; // Must exit before accessing freed memory

No C++ style comments please.
Comment 3 Michael Terry 2012-09-10 18:26:00 UTC
Done.

[master]
commit 5f353fa2b6d44a4be4e601b25f712e73736cd4c2
Author: Michael Terry <michael.terry@canonical.com>
Date:   Fri Sep 7 15:37:42 2012 -0400

    power: Use GCancellable better, to avoid a crash
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683533

[gnome-3.4]
commit 1801b2f4648b3e89b11cde7023c0046a98a0f1f1
Author: Michael Terry <michael.terry@canonical.com>
Date:   Mon Sep 10 14:24:12 2012 -0400

    power: Use GCancellable better, to avoid a crash
    
    https://bugzilla.gnome.org/show_bug.cgi?id=683533