[cairo] Question regarding cairo, freetype and multi-threaded execution.

Joseph Adamski-Smith joseph at adamski-smith.com
Fri Jul 27 08:15:51 PDT 2012


I have a crash inside freetype and it seems to be related to how cairo uses
freetype. But I am not very familiar to say for sure.

The crash call stack is below

current thread: t at 121
=>[1] af_latin_hints_compute_edges(*hints = 0x128623eb0*, dim =
AF_DIMENSION_HORZ), line 1039 in "aflatin.c"
  [2] af_latin_hints_detect_features(hints = 0x128623eb0, dim =
AF_DIMENSION_HORZ), line 1207 in "aflatin.c"
  [3] af_latin_hints_apply(hints = 0x128623eb0, outline = 0x100cb61b8,
metrics = 0x125a15f80), line 1951 in "aflatin.c"
  [4] af_loader_load_g(loader = 0x128623e98, scaler = 0xffffffff27edefb8,
glyph_index = 23U, load_flags = 2561, depth = 0), line 165 in "afloader.c"
  [5] af_loader_load_glyph(loader = 0x128623e98, face = 0x1282a00c0, gindex
= 23U, load_flags = 2561U), line 484 in "afloader.c"
  [6] af_autofitter_load_glyph(module = 0x128623e70, slot = 0x128086e90,
size = 0x1002135f0, glyph_index = 23U, load_flags = 512), line 57 in
"afmodule.c"
  [7] FT_Load_Glyph(*face = 0x1282a00c0*, glyph_index = 23U, load_flags =
512), line 612 in "ftobjs.c"
  [8] _cairo_ft_scaled_glyph_init(abstract_font = 0x1230a66a0, scaled_glyph
= 0x1243639c8, info = CAIRO_SCALED_GLYPH_INFO_METRICS), line 2159 in
"cairo-ft-font.c"
  [9] _cairo_scaled_glyph_lookup(scaled_font = 0x1230a66a0, index = 23U,
info = CAIRO_SCALED_GLYPH_INFO_METRICS, scaled_glyph_ret =
0xffffffff27edf520), line 2934 in "cairo-scaled-font.c"
  [10] cairo_scaled_font_text_to_glyphs_internal_uncached(scaled_font =
0x1230a66a0, x = 4.0, y = 0.0, utf8 = 0x124365cb0 "$  4,000", glyphs =
0x123354400, clusters = (nil), num_chars = 8), line 1755 in
"cairo-scaled-font.c"
  [11] cairo_scaled_font_text_to_glyphs(scaled_font = 0x1230a66a0, x = 0.0,
y = 0.0, utf8 = 0x124365cb0 "$  4,000", utf8_len = 8, glyphs =
0xffffffff27edf7c0, num_glyphs = 0xffffffff27edf7bc, clusters = (nil),
num_clusters = (nil), cluster_flags = (nil)), line 2076 in
"cairo-scaled-font.c"
  [12] cairo_text_extents(cr = 0x1243660c0, utf8 = 0x124365cb0 "$  4,000",
extents = 0xffffffff27edf8c0), line 3094 in "cairo.c"

The crash happens on the statement
found->last->edge_next = seg
At the time of crash found->last is null.

I found another thread executing in the same function
current thread: t at 102
=>[1] af_latin_hints_compute_edges(hints = 0x128623eb0, dim =
AF_DIMENSION_HORZ), line 1153 in "aflatin.c"
  [2] af_latin_hints_detect_features(hints = 0x128623eb0, dim =
AF_DIMENSION_HORZ), line 1207 in "aflatin.c"
  [3] af_latin_hints_apply(hints = 0x128623eb0, outline = 0x100cb61b8,
metrics = 0x1165c2310), line 1951 in "aflatin.c"
  [4] af_loader_load_g(loader = 0x128623e98, scaler = 0xffffffff2b7d6568,
glyph_index = 70U, load_flags = 2561, depth = 0), line 165 in "afloader.c"
  [5] af_loader_load_glyph(loader = 0x128623e98, face = 0x129c98910, gindex
= 70U, load_flags = 2561U), line 484 in "afloader.c"
  [6] af_autofitter_load_glyph(module = 0x128623e70, slot = 0x1165c65d0,
size = 0x103312420, glyph_index = 70U, load_flags = 512), line 57 in
"afmodule.c"
  [7] FT_Load_Glyph(face = 0x129c98910, glyph_index = 70U, load_flags =
512), line 612 in "ftobjs.c"
  [8] _cairo_ft_scaled_glyph_init(abstract_font = 0x124367000, scaled_glyph
= 0x122e96a48, info = CAIRO_SCALED_GLYPH_INFO_METRICS), line 2159 in
"cairo-ft-font.c"
  [9] _cairo_scaled_glyph_lookup(scaled_font = 0x124367000, index = 70U,
info = CAIRO_SCALED_GLYPH_INFO_METRICS, scaled_glyph_ret =
0xffffffff2b7d6ad0), line 2934 in "cairo-scaled-font.c"
  [10] cairo_scaled_font_text_to_glyphs_internal_cached(scaled_font =
0x124367000, x = 10.0, y = 0.0, utf8 = 0xffffffff2b7d7d0e "Secondary
Dataset 1", glyphs = 0x124360ef0, clusters = (nil), num_chars = 19), line
1695 in "cairo-scaled-font.c"
  [11] cairo_scaled_font_text_to_glyphs(scaled_font = 0x124367000, x = 0.0,
y = 0.0, utf8 = 0xffffffff2b7d7d0e "Secondary Dataset 1", utf8_len = 19,
glyphs = 0xffffffff2b7d7470, num_glyphs = 0xffffffff2b7d746c, clusters =
(nil), num_clusters = (nil), cluster_flags = (nil)), line 2069 in
"cairo-scaled-font.c"
  [12] cairo_text_extents(cr = 0x1243610c0, utf8 = 0xffffffff2b7d7d0e
"Secondary Dataset 1", extents = 0xffffffff2b7d7570), line 3094 in "cairo.c"

The hints object comes from the freetype library which is initialized once
in _cairo_ft_unscaled_font_map_create. So all the faces use the same
freetype library. Wouldn't this lead to race conditions?

The cairo version I am using is 1.12.2 and freetype is 2.2.1

Thank you
Joseph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20120727/50f8d451/attachment.html>


More information about the cairo mailing list