GNOME Bugzilla – Bug 641706
discoverer: Keep references on discoverer objects for callbacks
Last modified: 2011-02-22 12:50:23 UTC
Attaching a couple of patches that make sure we don't crash if the discoverer object disappears when there is a pending callback. The actual crashes are only exposed if commit e730ce71 is reverted, but should still be included for correctness.
Created attachment 180277 [details] [review] discoverer: Use g_signal_connect_object instead of g_signal_connect We want to make sure the discoverer object passed to the various callbacks doesn't become invalid if a callback is pending and the object is free'd in the mean time.
Created attachment 180278 [details] [review] discoverer: Keep a ref for the async timeout callback This makes sure we maintain a ref on the discoverer object while the async timeout callback is alive to prevent a potential crash if the object is freed while the callback is pending.
Btw, you're aware that g_signal_connect_object() will leak something. tp-glib has a hack around that (tp_g_signal_connect_object()).. But ideally it should be fixed in GLib itself I guess.
Comment on attachment 180277 [details] [review] discoverer: Use g_signal_connect_object instead of g_signal_connect Attaching a new patch which fixes the potential leak pointed out by Olivier.
Created attachment 180374 [details] [review] discoverer: Use g_signal_connect_object instead of g_signal_connect We want to make sure the discoverer object passed to the various callbacks doesn't become invalid if a callback is pending and the object is free'd in the mean time.
Comment on attachment 180374 [details] [review] discoverer: Use g_signal_connect_object instead of g_signal_connect This patch is wrong as well (throws up asserts that I somehow missed). Will update.
Created attachment 181159 [details] [review] discoverer: Use g_signal_connect_object instead of g_signal_connect We want to make sure the discoverer object passed to the various callbacks doesn't become invalid if a callback is pending and the object is free'd in the mean time.
All ok from me. Please commit.
commit 8d2b69384a2674873975b5414f7bb3635ff2014b Author: Arun Raghavan <arun.raghavan@collabora.co.uk> Date: Mon Feb 7 13:04:55 2011 +0530 discoverer: Keep a ref for the async timeout callback This makes sure we maintain a ref on the discoverer object while the async timeout callback is alive to prevent a potential crash if the object is freed while the callback is pending. https://bugzilla.gnome.org/show_bug.cgi?id=641706 commit 40c4fe8fbe23cc3e3293c737969fc274dfb6c4f1 Author: Arun Raghavan <arun.raghavan@collabora.co.uk> Date: Mon Feb 7 13:57:39 2011 +0530 discoverer: Use g_signal_connect_object instead of g_signal_connect We want to make sure the discoverer object passed to the various callbacks doesn't become invalid if a callback is pending and the object is free'd in the mean time. https://bugzilla.gnome.org/show_bug.cgi?id=641706