[cairo-commit] src/cairo-scaled-font.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Jun 18 08:14:24 PDT 2013


 src/cairo-scaled-font.c |    4 ++++
 1 file changed, 4 insertions(+)

New commits:
commit 519dff51db30e157f52ef5244a3afeea06340ff8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Jun 18 16:06:28 2013 +0100

    scaled-font: Prevent a recursive mutex lock for removing a failed glyph
    
    If we fail to create a glyph, and it is the only one in the glyph page,
    we then pluck that page out of the global glyph cache. The cache destroy
    callback tries to take the scaled_font lock again, causing a lockup.
    Rework the error path to avoid taking that lock in this case - still a
    potential lock ordering issue remains.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 97460c2..ac80c97 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2905,8 +2905,12 @@ _cairo_scaled_font_free_last_glyph (cairo_scaled_font_t *scaled_font,
 
     if (--page->num_glyphs == 0) {
 	CAIRO_MUTEX_LOCK (_cairo_scaled_glyph_page_cache_mutex);
+	/* Temporarily disconnect callback to avoid recursive locking */
+	cairo_scaled_glyph_page_cache.entry_destroy = NULL;
 	_cairo_cache_remove (&cairo_scaled_glyph_page_cache,
 		             &page->cache_entry);
+	_cairo_scaled_glyph_page_destroy (scaled_font, page);
+	cairo_scaled_glyph_page_cache.entry_destroy = _cairo_scaled_glyph_page_pluck;
 	CAIRO_MUTEX_UNLOCK (_cairo_scaled_glyph_page_cache_mutex);
     }
 }


More information about the cairo-commit mailing list