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 749659 - Cannot remove weak ref during the notify of another weak ref
Cannot remove weak ref during the notify of another weak ref
Status: RESOLVED DUPLICATE of bug 745678
Product: glib
Classification: Platform
Component: gobject
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 749660
 
 
Reported: 2015-05-21 03:12 UTC by Garrett Regier
Modified: 2015-10-22 18:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow a GObject weak ref notify to remove another weak ref (6.96 KB, patch)
2015-05-21 03:14 UTC, Garrett Regier
none Details | Review
Allow a GObject weak ref notify to remove another weak ref v2 (7.03 KB, patch)
2015-05-21 03:30 UTC, Garrett Regier
none Details | Review

Description Garrett Regier 2015-05-21 03:12:20 UTC
This causes a warning to be printed. Discovered while writing a test for Builder's EggStateMachine.
Comment 1 Garrett Regier 2015-05-21 03:14:31 UTC
Created attachment 303721 [details] [review]
Allow a GObject weak ref notify to remove another weak ref
Comment 2 Christian Hergert 2015-05-21 03:18:11 UTC
Thanks for tracking this down. Since we use weak refs so heavily this would be nice to get in this cycle.
Comment 3 Garrett Regier 2015-05-21 03:30:59 UTC
Created attachment 303722 [details] [review]
Allow a GObject weak ref notify to remove another weak ref v2

Minor cleanup
Comment 4 Allison Karlitskaya (desrt) 2015-05-21 14:38:48 UTC
I don't think this is really a bug -- see the duplicate for an explanation.

*** This bug has been marked as a duplicate of bug 745678 ***
Comment 5 Alexander Larsson 2015-10-22 18:05:09 UTC
Review of attachment 303722 [details] [review]:

::: gobject/gobject.c
@@ +2632,3 @@
+      g_array_remove_index_fast (weak_refs, 0);
+
+      tmp.notify (tmp.data, object);

In case of a weak ref cycle, will this not cause a g_warning() when the call back to remove the weak ref from this object fails to find the weak ref.

A more solid approach is probably to mark the weak ref as triggered, and then remove all weak refs at the end.