GNOME Bugzilla – Bug 662787
Segfaults when trying to set a large text size
Last modified: 2013-12-08 16:58:33 UTC
*Create a new file ; *Create a new text object, write some text in it ; *Select the text ; *Try to change size to a big value (I tried with 400) *GIMP instantly crashes Console output : $ gimp-2.7 This is a development version of GIMP. Debug messages may appear here. (script-fu:21417): LibGimpBase-WARNING **: script-fu: gimp_wire_read(): error Erreur de segmentation
Created attachment 200115 [details] [review] return if cairo fails to create a surface Setting a font size of 2048 px with font Sans and the text 56789012345678901234567890 with the attached patch I see the error message I added, removing the first 5 the text is rendered normally, without the patch I see the crash.
Duplicate of #85103, but leaving open because this is the first reasonable patch I've seen in 9 years. I think it makes sense to use an error dialog here via gimp_message().
*** Bug 85103 has been marked as a duplicate of this bug. ***
Created attachment 208917 [details] [review] same patch, using gimp_message
*** Bug 696009 has been marked as a duplicate of this bug. ***
Created attachment 253628 [details] [review] Patch to handle huge font size error. Hi, I could not reproduce the original crash by following the reproduction steps. But when testing, I encountered another issue with pango though, which has a font-size limit (which I also try to improve in Bug 707131). When I reach it (with value above 2000 pixels font-size basically), it would output a warning: "Value of 'size' attribute on <span> tag on line %d could not be parsed; should be an integer less than %d, or a string such as 'small', not '%s'" and fail to render. The attached patch refreshes the above patches (which were broken against current master code) and adds handling for the pango size error by outputting a nice error dialog telling the user why the rendering cannot be done.
Very nice. The usual pattern would however be to append a GError **error parameter and return an error instead of passing in a Gimp. Or did I already say that on IRC?
Mitch: no you didn't, or I was not there when you did. ;-) Ok I'll have a look back at my patch and update it then. May take a few days. This patch is kind of old so I don't remember at old the specifics. :p
Created attachment 257985 [details] [review] Patch to handle huge font size error. Hey Mitch, attached the new patch which passes GError** around. :-)
Excellent, one small glitch would be that in gimp_text_layout_set_markup() you'd rather use a local error instead of poking around in the error that got passed in. Fix that if you feel like it and push :)
I now free the glib error returned by pango and create a new locale GIMP_ERROR instead. :-) Pushed on master and soon on gimp-2-8. commit 2aabbbd9c733a9078d08b15bedef6e9adae1031f Author: Jehan <jehan@girinstud.io> Date: Sat Aug 31 03:16:44 2013 +1200 Bug 662787 - Segfaults when trying to set a large text size If a font size is too big for cairo or pango to deal with, nicely back up from rendering and alert the user via an error dialog.