GNOME Bugzilla – Bug 458458
Gtk2::Pango::Matrix->new leaks and lead to crash
Last modified: 2007-07-22 21:15:33 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
Created attachment 92009 [details] testcase
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.
Created attachment 92165 [details] [review] Use g_slice_new0 if appropriate
Thanks, it works in my program too, I want to use it to draw vertical text in a DrawingArea.
OK, committed to both branches.