[cairo] Assertion `! scaled_font->cache_frozen' failed

Bin Wu bin.wu at axis.com
Thu Jun 23 02:08:57 UTC 2016


Hi
Assertion: cairo-1.15.2/src/cairo-scaled-font.c:1317: cairo_scaled_font_destroy: Assertion `! scaled_font->cache_frozen' failed.

This happens in calling cairo_glyph_extents when several threads work on scaled_font.

Cairo_scaled_font_destroy is obviously unsafe for multithread, so the assertion may be triggered occasionally.

In my situation, following patch can solve my trouble
------------------------ cairo/src/cairo-scaled-font.c ------------------------
index ac80c97..bea10f4 100644
@@ -1314,6 +1314,8 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font)
     if (! _cairo_reference_count_dec_and_test (&scaled_font->ref_count))
        return;

+    CAIRO_MUTEX_LOCK(scaled_font->mutex);
+
     assert (! scaled_font->cache_frozen);
     assert (! scaled_font->global_cache_frozen);

@@ -1357,7 +1359,7 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font)

   unlock:
     _cairo_scaled_font_map_unlock ();
-
+    CAIRO_MUTEX_UNLOCK(scaled_font->mutex);
     /* If we pulled an item from the holdovers array, (while the font
      * map lock was held, of course), then there is no way that anyone
      * else could have acquired a reference to it. So we can now

So will cairo_scaled_font_destroy be optimized in further release?

BR
Bin Wu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20160623/978dfa85/attachment.html>


More information about the cairo mailing list