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 66199 - Potential memory leak in gtk_init
Potential memory leak in gtk_init
Status: RESOLVED WONTFIX
Product: glib
Classification: Platform
Component: gobject
1.3.x
Other opensolaris
: Normal minor
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2001-12-04 23:12 UTC by Hidetoshi Tajima
Modified: 2011-02-18 15:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
purify output of possible memory leak in GtypeNode (7.98 KB, text/plain)
2002-01-30 19:54 UTC, Hidetoshi Tajima
Details

Description Hidetoshi Tajima 2001-12-04 23:12:04 UTC
Purify reports potential memory leak from gtk_init() like below:      

PLK: 40 bytes potentially leaked at 0x96820
         This memory was allocated from:
               malloc         [rtlib.o]
               calloc         [rtlib.o]
               standard_calloc [glibgmem.c:111]
               g_malloc0      [glibgmem.c:154]
               type_node_any_new_W [gobjectgtype.c:287]
               type_node_fundamental_new_W [gobjectgtype.c:389]
               g_type_init_with_debug_flags [gobjectgtype.c:2886]
               g_type_init    [gobjectgtype.c:2942]
               gdk_init_check [gdkgdk.c:322]
               gtk_init_check [gtkgtkmain.c:467]
               gtk_init       [gtkgtkmain.c:672]
               main           [testtext.o]
Comment 1 Owen Taylor 2002-01-08 20:15:08 UTC
The problem here is that the   

g_hash_table_insert (static_type_nodes_ht,
		       GUINT_TO_POINTER (node->qname),
		       (gpointer) type);

At the end of type_node_any_new_W() is failing since
node->qname is 0. If this node doesn't need to be
accessed anywhwere we could either just stick a pointer
to the node into a static variable, or we could
try to never create it or free it.
Comment 2 Owen Taylor 2002-01-08 20:22:45 UTC
(Previous explanation was bogus, don't know what is going on)
Comment 3 Owen Taylor 2002-01-08 20:29:59 UTC
Tim points out that what is probably going on here is that
GLib does hacks where it doesn't keep a pointer to the
_beginning_ of the GTypeNode 

How do we get purify to figure this out so people can 
run purify on GLib programs do we have to hack around
this in some fashion? (I guess --enable-gc-friedly could
cause us to keep another array around to the beginning
of the fundamental types.)
Comment 4 Hidetoshi Tajima 2002-01-30 19:54:09 UTC
Created attachment 6557 [details]
purify output of possible memory leak in GtypeNode
Comment 5 Hidetoshi Tajima 2002-01-30 20:03:46 UTC
Attached is a new purify report about this PLK error which
I got with testgtk program in the gtk+ package. I ran it
and just immediately hit 'close' button. It seems that
g_type_init_with_debug_flags has created some GTypeNode
objects whose pointers are not kept.
Comment 6 Owen Taylor 2002-02-21 17:46:35 UTC
We think the problem is that GLib doesn't keep a pointer
to the beginning of the allocated block for fundamental
types. (It keeps a pointer to the GTypeNode, but allocates
a larger block, and subtracts to get the pointer to the
extended information.)'

Does this make sense that it would confuse purify?
Comment 7 Matthias Clasen 2002-06-07 08:37:55 UTC
valgrind reports the same - potentially leaked memory, meaning
that there is still a 
pointer to the middle of the block, just
not to the beginning. If this is intended (as 
you seem to imply),
I think we can close this.
Comment 8 Owen Taylor 2002-06-07 12:16:30 UTC
IMO, GLib should take the hit and keep pointers to the start
of the block as well to avoid problems for people using memory
leak detection tools; Tim disagrees...