Commit 6dfdaf4d99e435250eb18582fa60b59dc3bbc427

Behdad Esfahbod 2015-01-14T18:21:13

[base] Do not reorder library->renderers upon use. Instead of keeping `library->renderers' in a MRU order, just leave it as-is. The MRU machinery wasn't thread-safe. With this patch, rasterizing glyphs from different faces from different threads doesn't fail choosing rasterizer (FT_Err_Cannot_Render_Glyph). Easiest to see that crash was to add a `printf' (or otherwise let thread yield in FT_Throw with debugging enabled). * src/base/ftobjs.c (FT_Render_Glyph_Internal), src/base/ftoutln.c (FT_Outline_Render): Don't call `FT_Set_Renderer'.

diff --git a/ChangeLog b/ChangeLog
index 51d05a2..b1b6ba8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
 2015-01-14  Behdad Esfahbod  <behdad@behdad.org>
 
+	[base] Do not reorder library->renderers upon use.
+
+	Instead of keeping `library->renderers' in a MRU order, just leave
+	it as-is.  The MRU machinery wasn't thread-safe.
+
+	With this patch, rasterizing glyphs from different faces from
+	different threads doesn't fail choosing rasterizer
+	(FT_Err_Cannot_Render_Glyph).
+
+	Easiest to see that crash was to add a `printf' (or otherwise let
+	thread yield in FT_Throw with debugging enabled).
+
+	* src/base/ftobjs.c (FT_Render_Glyph_Internal), src/base/ftoutln.c
+	(FT_Outline_Render): Don't call `FT_Set_Renderer'.
+
+2015-01-14  Behdad Esfahbod  <behdad@behdad.org>
+
 	[raster] Allocate render pool for mono rasterizer on the stack.
 
 	Instead of using the `render_pool' member of `FT_Library' that is
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index ee15a01..6d685b5 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4084,8 +4084,7 @@
 
     default:
       {
-        FT_ListNode  node   = 0;
-        FT_Bool      update = 0;
+        FT_ListNode  node = 0;
 
 
         /* small shortcut for the very common case */
@@ -4112,16 +4111,6 @@
           /* now, look for another renderer that supports the same */
           /* format.                                               */
           renderer = FT_Lookup_Renderer( library, slot->format, &node );
-          update   = 1;
-        }
-
-        /* if we changed the current renderer for the glyph image format */
-        /* we need to select it as the next current one                  */
-        if ( !error && update && renderer )
-        {
-          error = FT_Set_Renderer( library, renderer, 0, 0 );
-          if ( error )
-            break;
         }
       }
     }
diff --git a/src/base/ftoutln.c b/src/base/ftoutln.c
index 8749d64..45f074c 100644
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -612,7 +612,6 @@
                      FT_Raster_Params*  params )
   {
     FT_Error     error;
-    FT_Bool      update = FALSE;
     FT_Renderer  renderer;
     FT_ListNode  node;
 
@@ -646,14 +645,8 @@
       /* format                                                */
       renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
                                      &node );
-      update   = TRUE;
     }
 
-    /* if we changed the current renderer for the glyph image format */
-    /* we need to select it as the next current one                  */
-    if ( !error && update && renderer )
-      error = FT_Set_Renderer( library, renderer, 0, 0 );
-
     return error;
   }