mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-01 23:13:40 +02:00
gobject: fix deadlock with g_weak_ref_set()
In general, we must not call out to external, unknown code while holding a lock. That is prone to dead lock. g_object_ref() can emit a toggle notification. In g_weak_ref_set(), we must not do that while holding the lock.
This commit is contained in:
@@ -731,11 +731,9 @@ weak_ref_in_toggle_notify_toggle_cb (gpointer data,
|
||||
return;
|
||||
|
||||
/* We just got a second ref, while calling g_weak_ref_get().
|
||||
* At this point, we hold a lock for the weak ref.
|
||||
*
|
||||
* FIXME: currently we would dead lock with the lines below.
|
||||
* Test that taking another weak ref in this situation works.
|
||||
*/
|
||||
return;
|
||||
|
||||
g_weak_ref_init (&weak2, object);
|
||||
g_assert_true (object == g_weak_ref_get (&weak2));
|
||||
|
Reference in New Issue
Block a user