[cairo-commit] src/cairoint.h
Carl Worth
cworth at kemper.freedesktop.org
Thu Mar 1 23:51:59 PST 2007
src/cairoint.h | 5 ++++-
1 files changed, 4 insertions(+), 1 deletion(-)
New commits:
diff-tree d48bb4fbe876a93199ba48fcf5f32734fbe18ba9 (from df2d42ac7fb71997abd406fb5716c0bd85037c04)
Author: Carl Worth <cworth at cworth.org>
Date: Thu Mar 1 23:34:34 2007 -0800
Implement CAIRO_MUTEX_INIT with memcpy instead of pthread_mutex_init
The trick here is that with the weak symbol support for pthreads,
pthread_mutex_init can be a NOP leaving the mutex uninitialized.
Then, if some pthread-using library is dynamically loaded, the
non-NOP pthread functions get used and we end up trying to lock
an uninitialized mutex.
This should fix the bugs reported here:
Cairo 1.3.14 deadlocks in cairo_scaled_font_glyph_extents or _cairo_ft_unscaled_font_lock_face
https://bugs.freedesktop.org/show_bug.cgi?id=10035
diff --git a/src/cairoint.h b/src/cairoint.h
index 890929f..3a2d845 100755
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -141,7 +141,10 @@ CAIRO_BEGIN_DECLS
# define CAIRO_MUTEX_LOCK(name) pthread_mutex_lock (&name)
# define CAIRO_MUTEX_UNLOCK(name) pthread_mutex_unlock (&name)
typedef pthread_mutex_t cairo_mutex_t;
-# define CAIRO_MUTEX_INIT(mutex) pthread_mutex_init ((mutex), NULL)
+#define CAIRO_MUTEX_INIT(mutex) do { \
+ pthread_mutex_t tmp_mutex = PTHREAD_MUTEX_INITIALIZER; \
+ memcpy (mutex, &tmp_mutex, sizeof (tmp_mutex)); \
+} while (0)
# define CAIRO_MUTEX_FINI(mutex) pthread_mutex_destroy (mutex)
# define CAIRO_MUTEX_NIL_INITIALIZER PTHREAD_MUTEX_INITIALIZER
#endif
More information about the cairo-commit
mailing list