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 616655 - Gtk2::Gdk::Window destruction doesn't work correctly
Gtk2::Gdk::Window destruction doesn't work correctly
Status: RESOLVED FIXED
Product: gnome-perl
Classification: Bindings
Component: Gtk2
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk2-perl-bugs
gtk2-perl-bugs
Depends on:
Blocks:
 
 
Reported: 2010-04-23 14:59 UTC by Quentin Sculo
Modified: 2010-11-23 20:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (235 bytes, application/x-perl)
2010-04-23 14:59 UTC, Quentin Sculo
Details
failing program (221 bytes, text/x-perl)
2010-09-07 00:24 UTC, Kevin Ryde
Details
loop program which doesn't leak memory, but does provoke the _noinc problem (246 bytes, text/x-perl)
2010-09-07 00:25 UTC, Kevin Ryde
Details

Description Quentin Sculo 2010-04-23 14:59:26 UTC
Created attachment 159437 [details]
test case

When creating a child Gtk2::Gdk::Window, I get an error when closing the program. 
Either "Gdk-WARNING **: losing last reference to undestroyed window" if I didn't call destroy on the child gdkwindow,
or "Attempt to free unreferenced scalar: SV 0x9a8ca78, Perl interpreter: 0x9a6b008." if I called destroy on the child gdkwindow.
(see attached test case)

Looking further, creating and destroying child gdkwindows continuously leaks some memory, and doing the same with toplevel gdkwindows ends up with an error.

Replacing "GdkWindow_noinc * gdk_window_new" by "GdkWindow * gdk_window_new" in xs/GdkWindow.xs seems to fix it, though I don't know enough about gtk and the bindings to be sure it's the correct fix.
Comment 1 Kevin Ryde 2010-09-07 00:23:55 UTC
Yes.  It happens to a toplevel window too, per attached toplevel.pl.  Removing the _noinc from gdk_window_new() fixes it for me too.

But I don't think there's a memory leak.  If you run some main loop iterations per attached noleak.pl then the memory is steady.  I imagine it's notify events or whatever coming back from the server.

Is a GdkWindow kept alive by it's place in the "list_toplevels" thingie, or by its parent when not a toplevel?  So if you clear your perl scalar before the it's removed from there then no problem, but if the scalar lasts after that then there's a missing g_object_ref() for that scalar.
Comment 2 Kevin Ryde 2010-09-07 00:24:35 UTC
Created attachment 169634 [details]
failing program
Comment 3 Kevin Ryde 2010-09-07 00:25:25 UTC
Created attachment 169635 [details]
loop program which doesn't leak memory, but does provoke the _noinc problem
Comment 4 Torsten Schoenfeld 2010-11-23 20:26:45 UTC
Yes, I think you are both correct.  The current "transfer none" annotation also agrees.  So I committed the suggested change to master and the stable-1-22 branch.  Thanks for the report.