NULL dereference in font_has_color_glyphs when uninstalling font at run time
I got a crash in font_has_color_glyphs()
on 41.1 today. The trigger seems to have been dnf autoremove uninstalling bitstream-vera-sans-fonts yesterday and me not having restarted the shell since then.
The scaled font has a status of CAIRO_STATUS_NO_MEMORY
, but unlike what this seems to indicate this was not due to insufficient memory. Instead this seems to come from _cairo_ft_unscaled_font_lock_face()
failing, which I presume is due to FT_New_Face()
failing since there is no more file under the path it is trying to open. _cairo_ft_has_color_glyphs()
seems to guard against it failing with a NULL
check, maybe cogl-pango should do the same? That might just move the crash to a later point though or might still result in missing/broken glyphs though.
Is there maybe some signal when font files change that we could use to clear the glyph cache instead?
#0 0x00007f61cbeb31bb in font_has_color_glyphs (font=0x55818dbaa320) at ../cogl/cogl-pango/cogl-pango-render.c:541
#1 cogl_pango_renderer_set_dirty_glyph (font=0x55818dbaa320, font@entry=<error reading variable: value has been optimized out>, glyph=21, glyph@entry=<error reading variable: value has been optimized out>, value=0x558192d1b7a0, value@entry=<error reading variable: value has been optimized out>) at ../cogl/cogl-pango/cogl-pango-render.c:623
#2 0x00007f61cbeb235c in _cogl_pango_glyph_cache_set_dirty_glyphs_cb (key_ptr=<optimized out>, value_ptr=0x558192d1b7a0, user_data=<optimized out>) at ../cogl/cogl-pango/cogl-pango-glyph-cache.c:386
#3 0x00007f61cc9b87f8 in g_hash_table_foreach (hash_table=0x55818b373a40 = {...}, func=0x7f61cbeb2340 <_cogl_pango_glyph_cache_set_dirty_glyphs_cb>, user_data=0x7f61cbeb3000 <cogl_pango_renderer_set_dirty_glyph>) at ../glib/ghash.c:2065
#4 0x00007f61cbeb4a3f in _cogl_pango_glyph_cache_set_dirty_glyphs (func=0x7f61cbeb3000 <cogl_pango_renderer_set_dirty_glyph>, cache=0x55818b348840) at ../cogl/cogl-pango/cogl-pango-glyph-cache.c:393
#5 _cogl_pango_glyph_cache_set_dirty_glyphs (func=0x7f61cbeb3000 <cogl_pango_renderer_set_dirty_glyph>, cache=0x55818b348840) at ../cogl/cogl-pango/cogl-pango-glyph-cache.c:393
#6 _cogl_pango_set_dirty_glyphs (priv=<optimized out>) at ../cogl/cogl-pango/cogl-pango-render.c:665
#7 cogl_pango_ensure_glyph_cache_for_layout (layout=layout@entry=0x55818dc7b640) at ../cogl/cogl-pango/cogl-pango-render.c:714
#8 0x00007f61cbf64d59 in clutter_text_create_layout (text=text@entry=0x5581943e1980, allocation_width=allocation_width@entry=-1, allocation_height=allocation_height@entry=-1) at ../clutter/clutter/clutter-text.c:1106
#9 0x00007f61cbf6516a in clutter_text_get_preferred_width (self=0x5581943e1980, for_height=<optimized out>, min_width_p=0x7ffe6e29b7d4, natural_width_p=0x7ffe6e29b7d0) at ../clutter/clutter/clutter-text.c:2932
#10 0x00007f61cbf06d40 in clutter_actor_get_preferred_width (self=0x5581943e1980, for_height=-1, min_width_p=min_width_p@entry=0x7ffe6e29b894, natural_width_p=natural_width_p@entry=0x7ffe6e29b890) at ../clutter/clutter/clutter-actor.c:8709
#11 0x00007f61cb9ec31d in st_label_get_preferred_width (actor=<optimized out>, for_height=<optimized out>, min_width_p=0x7ffe6e29b894, natural_width_p=0x7ffe6e29b890) at ../src/st/st-label.c:141
#12 0x00007f61cbf06d40 in clutter_actor_get_preferred_width (self=0x55818f0d4d50, for_height=-1, min_width_p=0x558193b86928, natural_width_p=0x558193b86930) at ../clutter/clutter/clutter-actor.c:8709
(gdb) print ft_face
$2 = (FT_Face) 0x0
(gdb) print *scaled_font
$10 = {hash_entry = {hash = 2131782400}, status = CAIRO_STATUS_NO_MEMORY, ref_count = {ref_count = 1}, user_data = {size = 0, num_elements = 0, element_size = 24, elements = 0x0}, original_font_face = 0x55818bac3bf0, font_face = 0x55818bac3bf0, font_matrix = {xx = 16, yx = 0, xy = 0, yy = 16, x0 = 0, y0 = 0}, ctm = {xx = 1, yx = 0, xy = 0, yy = 1, x0 = 0, y0 = 0}, options = {antialias = CAIRO_ANTIALIAS_GRAY, subpixel_order = CAIRO_SUBPIXEL_ORDER_RGB, lcd_filter = CAIRO_LCD_FILTER_DEFAULT, hint_style = CAIRO_HINT_STYLE_SLIGHT, hint_metrics = CAIRO_HINT_METRICS_DEFAULT, round_glyph_positions = CAIRO_ROUND_GLYPH_POS_DEFAULT, variations = 0x0}, placeholder = 0, holdover = 0, finished = 0, scale = {xx = 16, yx = 0, xy = 0, yy = 16, x0 = 0, y0 = 0}, scale_inverse = {xx = 0.0625, yx = 0, xy = 0, yy = 0.0625, x0 = -0, y0 = -0}, max_scale = 16, extents = {ascent = 15, descent = 4, height = 19, max_x_advance = 23, max_y_advance = 0}, fs_extents = {ascent = 0.9375, descent = 0.25, height = 1.1875, max_x_advance = 1.4375, max_y_advance = 0}, mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}, glyphs = 0x558190ca3400, glyph_pages = {next = 0x558191953818, prev = 0x558193242658}, cache_frozen = 0, global_cache_frozen = 0, dev_privates = {next = 0x7f61a41ceba0, prev = 0x7f61a41ceba0}, backend = 0x7f61cb8b08e0 <_cairo_ft_scaled_font_backend>, link = {next = 0x7f61a41cebb8, prev = 0x7f61a41cebb8}}
(gdb) print *((cairo_ft_scaled_font_t *) scaled_font)->unscaled
$13 = {base = {hash_entry = {hash = 11530805526019070102}, ref_count = {ref_count = 3}, backend = 0x7f61cb8b0710 <cairo_ft_unscaled_font_backend>}, from_face = 0, face = 0x0, filename = 0x55818f031a90 "/usr/share/fonts/bitstream-vera-sans-fonts/VeraBd.ttf", id = 0, have_scale = 0, current_scale = {xx = 16, yx = 0, xy = 0, yy = 16, x0 = 0, y0 = 0}, x_scale = 16, y_scale = 16, have_shape = 0, current_shape = {xx = 1, yx = 0, xy = 0, yy = 1, x0 = 0, y0 = 0}, Current_Shape = {xx = 65536, xy = 0, yx = 0, yy = 65536}, have_color_set = 1, have_color = 0, variations = 0x0, mutex = {__data = {__lock = 0, __count = 0, __owner = 0, __nusers = 0, __kind = 0, __spins = 0, __elision = 0, __list = {__prev = 0x0, __next = 0x0}}, __size = '\000' <repeats 39 times>, __align = 0}, lock_count = 0, faces = 0x55818bac3bf0}