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 458458 - Gtk2::Pango::Matrix->new leaks and lead to crash
Gtk2::Pango::Matrix->new leaks and lead to crash
Status: RESOLVED FIXED
Product: gnome-perl
Classification: Bindings
Component: Gtk2
unspecified
Other All
: Normal normal
: ---
Assigned To: gtk2-perl-bugs
gtk2-perl-bugs
Depends on:
Blocks:
 
 
Reported: 2007-07-19 23:50 UTC by Quentin Sculo
Modified: 2007-07-22 21:15 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18


Attachments
testcase (202 bytes, text/plain)
2007-07-19 23:53 UTC, Quentin Sculo
  Details
Use g_slice_new0 if appropriate (599 bytes, patch)
2007-07-22 11:42 UTC, Torsten Schoenfeld
none Details | Review

Description Quentin Sculo 2007-07-19 23:50:42 UTC
Please describe the problem:
Gtk2::Pango::Matrix->new leaks memory and leads to a crash, either a segmentation fault or a GSlice error

Steps to reproduce:
repeatedly calling Gtk2::Pango::Matrix->new (see attachment)

Actual results:
segmentation fault
or
***MEMORY-ERROR***: bug_matrix.pl[19052]: GSlice: assertion failed: sinfo->n_allocated > 0

Expected results:


Does this happen every time?
Crash after a variable number of calls, around 1 milion calls on my system with the attached test script that does only that, I think the crash happens much sooner in a real program.

Other information:
Don't know if it's a Gtk or bindings bug
Comment 1 Quentin Sculo 2007-07-19 23:53:31 UTC
Created attachment 92009 [details]
testcase
Comment 2 Torsten Schoenfeld 2007-07-22 11:40:46 UTC
That's a bindings bug, kind of.  Since pango doesn't provide a pango_matrix_new, we roll our own in the bindings using g_new0.  But starting with 1.12.0 (revision 1696 in SVN), pango changed every memory allocation code to use GSlice.  That means we now allocate a PangoMatrix struct with g_new0 and then pango frees it with g_slice_free.

The attached patch fixes the issue for me.
Comment 3 Torsten Schoenfeld 2007-07-22 11:42:26 UTC
Created attachment 92165 [details] [review]
Use g_slice_new0 if appropriate
Comment 4 Quentin Sculo 2007-07-22 20:53:37 UTC
Thanks, it works in my program too, I want to use it to draw vertical text in a DrawingArea.
Comment 5 Torsten Schoenfeld 2007-07-22 21:15:33 UTC
OK, committed to both branches.