GNOME Bugzilla – Bug 314239
pangocairo crashes when font cannot be read
Last modified: 2006-02-21 11:42:06 UTC
Distribution/Version: Mandriva cooker to duplicate : -in a directory used by fontconfig, move one of the font file in /tmp and do ln -s /tmp/your_font_file.ttf testfont.ttf -run fc-cache -break the symlink (mv /tmp/your_font_file.ttf /tmp/your_font_file_renamed.ttf) -run gnome-font-property and try to select the font you just renamed => crash backtrace : Program received signal SIGSEGV, Segmentation fault.
+ Trace 62595
Thread NaN (LWP 19257)
metrics metrics_by_lang (gdb) print metrics $1 = (PangoFontMetrics *) 0x821c078 (gdb) print *metrics $2 = {ref_count = 1, ascent = 0, descent = 0, approximate_char_width = 0, approximate_digit_width = 0, underline_position = 0, underline_thickness = 0, strikethrough_position = 0, strikethrough_thickness = 0} (gdb) print face $3 = 0x0 this crash is a regression compared to pango 1.8.x which was able to get a fallback font with this particular testcase.
Hmmm I cannot confirm on Debian with Gnome 2.11.92
*** Bug 321429 has been marked as a duplicate of this bug. ***
*** Bug 326815 has been marked as a duplicate of this bug. ***
*** Bug 328872 has been marked as a duplicate of this bug. ***
Created attachment 58312 [details] [review] patch to not crash This patch crudely changes pango to not crash if a font is not accessible. Instead, it most probably draws unknown boxes, or uses a fixed font... This happens because we only create cairo_scaled_font when we need to access the font. Instead, I guess, we should try to lock/access the scaled_font when choosing the proper font. This way when a font is not accessible, we will just skip and choose the next font.
Note that the patch leaks, if it's not obvious...
This will be fixed in the next release (not the upcoming one), as it's pending on cairo release.
*** Bug 318863 has been marked as a duplicate of this bug. ***
Ok, I committed a (rather dirty) hack to fix this problem. It doesn't crash, just draw boxes instead. It's just a hack though, and may fail in certain situations. What I did was checking for NULLs in a few places, but not all places as that would have injured the code too harmfully. The proper fix has got to wait until 1.13... Test and attach backtraces if still happens. 2006-02-21 Behdad Esfahbod <behdad@gnome.org> Bug 314239 – pangocairo crashes when font cannot be read * pango/pangocairo-fcfont.c, pango/pangocairo-font.c: Hack up to not crash if we cannot create cairo_scaled_font_t for PangoFont (font is not readable, removed, etc.)