GNOME Bugzilla – Bug 66513
gconf_client_get_default returns a refcount
Last modified: 2018-08-17 13:55:52 UTC
This is one big memory leak, GTK/GNOME API conventions in no way suggest that this should return a new refcount. It's broken broken broken.
http://svn.gnome.org/viewvc/gconf/trunk/gconf/gconf-client.c?revision=2355&view=markup client = g_object_new (gconf_client_get_type (), NULL); // this is the leak g_object_ref (G_OBJECT (client)); set_engine (client, engine); register_client (client); Can't we fix that. Otherwise non of the gconfclients ever get unreffed.
It is not API compatible to fix it. Right now apps would be correct to unref the returned client. The right fix is to get Ryan to finish dconf (or help him do so)
Havoc, yes and the still are correct. The problem is that thsi code on the application side not leads to disposal of the gconf client: client = gconf_client_get_default(); // do something g_object_unref (client); The g_object_new() already creates a ref_count of 1. So all I want to do is to remove the errornous g_object_ref (G_OBJECT (client)); Why do you think this is an *ABI* change?
Oh, this bug is about gconf_client_get_default() returns one refcount. You're saying there's a separate bug that in some cases it returns two. Fixing that sounds fine to me (but then again, I have not touched gconf in 5+ years, so it is not terribly relevant what I think)
Yes, the issue is that basically when it return an existing client it refs (which is correct), but when it creates the client for the first time it does _new and _ref. Thats the only issue I see. I'll make a patch, where I remove the additional ref and use a weak_pointer for the engine.
I was investigating one bug in Unity2d [0], which I believe is caused by this: when GConf receives the HUP signal, it reloads the DB, which causes the D-Bus object path of the DB to change. Unfortunately, all the living GConfClient instances are not notified of the change (this might deserve a separate bug report); and because of this reference count created on the first call of gconf_client_get_default(), this means that all GConfClient instances returned by gconf_client_get_default() stop working after gconfd receives the HUP signal. One solution might be to change the g_object_ref() in gconf_client_get_default() with a g_object_weak_ref(). Or indeed, use DConf. [0] https://bugs.launchpad.net/gconf/+bug/820274
GConf has been deprecated since 2011. GConf is not under active development anymore. Its codebase has been archived: https://gitlab.gnome.org/Archive/gconf/commits/master dconf and gsettings are its successors. See https://developer.gnome.org/gio/stable/ch34.html and https://developer.gnome.org/GSettings/ for porting info. Closing this report as WONTFIX as part of Bugzilla Housekeeping to reflect reality. Feel free to open a task in GNOME Gitlab if the issue described in this task still applies to a recent + supported version of dconf/gsettings. Thanks!