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 66513 - gconf_client_get_default returns a refcount
gconf_client_get_default returns a refcount
Status: RESOLVED WONTFIX
Product: GConf
Classification: Deprecated
Component: gconf
CVS HEAD
Other Linux
: Normal normal
: ABI change
Assigned To: GConf Maintainers
GConf Maintainers
gnome[unmaintained]
Depends on:
Blocks:
 
 
Reported: 2001-12-08 18:01 UTC by Havoc Pennington
Modified: 2018-08-17 13:55 UTC
See Also:
GNOME target: ---
GNOME version: 2.9/2.10



Description Havoc Pennington 2001-12-08 18:01:09 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.
Comment 1 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-09 14:12:13 UTC
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.
Comment 2 Havoc Pennington 2008-04-09 15:42:45 UTC
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)
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-09 17:27:29 UTC
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?
Comment 4 Havoc Pennington 2008-04-09 18:19:33 UTC
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)
Comment 5 Stefan Sauer (gstreamer, gtkdoc dev) 2008-04-09 18:25:29 UTC
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.
Comment 6 Mardy 2011-08-23 08:08:16 UTC
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
Comment 7 André Klapper 2018-08-17 13:55:52 UTC
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!