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 614345 - 'destroy_data' in g_cclosure_new is registered as finalize notifier instread invalidate.
'destroy_data' in g_cclosure_new is registered as finalize notifier instread ...
Status: RESOLVED OBSOLETE
Product: glib
Classification: Platform
Component: gobject
2.24.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2010-03-30 10:35 UTC by Andrey Tsyvarev
Modified: 2018-05-24 12:09 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Andrey Tsyvarev 2010-03-30 10:35:37 UTC
Documentation states about g_cclosure_new:

Creates a new closure which invokes callback_func with user_data as the last parameter.

callback_func :	the function to invoke 
user_data :	user data to pass to callback_func 
destroy_data :	destroy notify to be called when user_data is no longer used 
Returns :	a new GCClosure

From this description, 'user_data' became a value of the 'data' field of the GClosure created.
This value becomes unused inside closure, when g_closure_invalidate is called.

So, one may expect, that 'destroy_data' function is called in result of g_closure_invalidate (simply, is registered with g_closure_add_invalidate_notifier). But actually, this function is registered with g_closure_add_finalize_notifier, and is called only when closure is destroyed.

After the closure is invalidated, it may be a while before it is destroyed (if g_closure_invalidate is called not in the result of g_closure_unref).

Moreover, one may drop the last reference to the closure in 'destroy_data' function, and expect that this mechanism will be activated when g_closure_invalidate is called (otherwise, finalization of closure doesn't occur at all.).

So, registering 'destroy_data' as finalization notifier instead of invalidation one is incorrect from the view of documentation and may lead to unneeded usage of the system's resources and even to errors in program's logic.

Also, it is worth to note that in the g_cclosure_new_object notification function is registered as invalidate notifier(via g_object_watch_closure).
Comment 1 GNOME Infrastructure Team 2018-05-24 12:09:50 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/277.