babl-fish-reference: add lock to part of float reference
authorØyvind Kolås <pippin@gimp.org>
Tue, 4 Sep 2018 17:09:07 +0000 (19:09 +0200)
committerØyvind Kolås <pippin@gimp.org>
Tue, 4 Sep 2018 17:09:28 +0000 (19:09 +0200)
This fixes problems that occur during GEGLs documentation gallery build
when multiple threads are in use (the default). The critical section has
experimentally been made as short as possible to avoid babl memory
inconsistencies - without identifing the core race.

babl/babl-fish-reference.c
babl/babl-internal.c
babl/babl-internal.h
tools/babl_fish_path_fitness.c

index 619ceb58b7ada18920feacc0ae76df7816a3090d..6d1aa840298eaed0a5224879206cf8d761e97958 100644 (file)
@@ -900,6 +900,7 @@ babl_fish_reference_process_float (const Babl *babl,
       return;
     }
 
+    babl_mutex_lock (babl_reference_mutex);
     if (babl->fish.source->format.type[0] == type_float &&
         BABL(babl->fish.source)->format.components ==
         BABL(babl->fish.source)->format.model->components && 0)
@@ -961,6 +962,7 @@ babl_fish_reference_process_float (const Babl *babl,
           n);
       }
     }
+    babl_mutex_unlock (babl_reference_mutex);
 
     if (((babl->fish.source)->format.space !=
         ((babl->fish.destination)->format.space)))
index 2f3c42e5b1c6fe1e61abc81ab8b9c400e6cf7e1f..5609720b0fcc5101ab27e8f4ab06ad519295fb8d 100644 (file)
@@ -82,6 +82,7 @@ BablMutex *babl_format_mutex;
 #if BABL_DEBUG_MEM
 BablMutex *babl_debug_mutex;
 #endif
+BablMutex *babl_reference_mutex;
 
 void
 babl_internal_init (void)
@@ -89,6 +90,7 @@ babl_internal_init (void)
   babl_set_malloc (malloc);
   babl_set_free (free);
   babl_format_mutex = babl_mutex_new ();
+  babl_reference_mutex = babl_mutex_new ();
 #if BABL_DEBUG_MEM
   babl_debug_mutex = babl_mutex_new ();
 #endif
@@ -98,6 +100,7 @@ void
 babl_internal_destroy (void)
 {
   babl_mutex_destroy (babl_format_mutex);
+  babl_mutex_destroy (babl_reference_mutex);
 #if BABL_DEBUG_MEM
   babl_mutex_destroy (babl_debug_mutex);
 #endif
index 8f3143409ff8c6c431c15660058b7d6f32848806..73fe18f00ea624da8f278091d34057cc508cc949 100644 (file)
@@ -242,6 +242,7 @@ babl_fatal (const char *format, ...)
 extern int   babl_hmpf_on_name_lookups;
 extern int   babl_in_fish_path;
 extern BablMutex *babl_format_mutex;
+extern BablMutex *babl_reference_mutex;
 
 #define BABL_DEBUG_MEM 0
 #if BABL_DEBUG_MEM
index ffd81abd78a2852a2d2feb37c2a93dca4642d528..92c5935573426b81062876ca49fc35760ffcf31b 100644 (file)
@@ -56,7 +56,7 @@ static char *utf8_bar[]={"·", "█", "▇", "▆", "▅", "▄", "▃", "▂",
 static char *utf8_bar[]={" ","1","2","3","4","5","6","7","8"};
 */
 
-#define NUM_TEST_PIXELS  (1024*16)
+#define NUM_TEST_PIXELS  (1024*1024)
 static float test_pixels_float[NUM_TEST_PIXELS*4];
 static char  test_pixels_in[NUM_TEST_PIXELS * 6 * 8];
 static char  test_pixels_out[NUM_TEST_PIXELS * 6 * 8];