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 749678 - Improve GObjectNotifyQueue usage
Improve GObjectNotifyQueue usage
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gobject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2015-05-21 11:21 UTC by Garrett Regier
Modified: 2018-05-24 17:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Prevent deadlock in g_object_notify_queue_add() (1.02 KB, patch)
2015-05-21 11:23 UTC, Garrett Regier
needs-work Details | Review
Use a GPtrArray for the GObjectNotifyQueue (3.95 KB, patch)
2015-05-21 11:24 UTC, Garrett Regier
reviewed Details | Review
Use g_datalist_id_replace_data() for GObjectNotifyQueue (2.03 KB, patch)
2015-05-21 11:32 UTC, Garrett Regier
rejected Details | Review

Description Garrett Regier 2015-05-21 11:21:43 UTC
Looking at the code revealed a number of changes could be made. Patches to follow.
Comment 1 Garrett Regier 2015-05-21 11:23:29 UTC
Created attachment 303747 [details] [review]
Prevent deadlock in g_object_notify_queue_add()

If too many GParamSpecs are queued we would leave the notify_lock locked.
Comment 2 Garrett Regier 2015-05-21 11:24:32 UTC
Created attachment 303748 [details] [review]
Use a GPtrArray for the GObjectNotifyQueue

The contents are reversed before calling dispatch_properties_changed() to replicate
the old behavior.

----

There is a test that requires the old behavior, no idea if it is actually required.
Comment 3 Garrett Regier 2015-05-21 11:32:36 UTC
Created attachment 303749 [details] [review]
Use g_datalist_id_replace_data() for GObjectNotifyQueue

This further limits the time the notify_lock is held and allows us to avoid the lock in the conditional path.
Comment 4 Allison Karlitskaya (desrt) 2015-05-21 14:22:31 UTC
Review of attachment 303747 [details] [review]:

You shouldn't access n_pspecs without the lock held.

I consider it basically impossible for this case to be hit, and if it ever is hit, the program is going to misbehave -- I'd rather it was just converted into an assert inside of the lock.
Comment 5 Allison Karlitskaya (desrt) 2015-05-21 14:23:17 UTC
Review of attachment 303748 [details] [review]:

Changes like this should come with benchmark numbers...
Comment 6 Allison Karlitskaya (desrt) 2015-05-21 14:26:37 UTC
Review of attachment 303749 [details] [review]:

::: gobject/gobject.c
@@ +234,3 @@
       nqueue->pspecs = g_ptr_array_new ();
+
+      if (!g_datalist_id_replace_data (&object->qdata, quark_notify_queue,

This approach doesn't work.

g_object_notify_queue_thaw() sets the qdata back to NULL.

If that is happening in another thread then we could see ourselves with a failure to set this (because it was not yet NULL) followed by reading out NULL below (since the other thread meanwhile changed the value).
Comment 7 Matthias Clasen 2015-09-07 23:59:53 UTC
Comment on attachment 303747 [details] [review]
Prevent deadlock in g_object_notify_queue_add()

I've changed the return-if-fail to an assertion now.
Comment 8 GNOME Infrastructure Team 2018-05-24 17:51:08 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/glib/issues/1040.