[cairo-bugs] [Bug 10035] Cairo 1.3.14 deadlocks in cairo_scaled_font_glyph_extents or _cairo_ft_unscaled_font_lock_face

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Mar 2 00:00:37 PST 2007


------- Comment #12 from cworth at cworth.org  2007-03-02 00:00 PST -------
Created an attachment (id=8941)
 --> (http://bugs.freedesktop.org/attachment.cgi?id=8941&action=view)
FIX: Implement CAIRO_MUTEX_INIT with memcpy instead of pthread_mutex_init

I'm happy to report that we've got a fix for this, (many thanks to Kjartan
Maraas  for giving me access to his machine so I could replicate the bug and
confirm the fix). And thanks also to Ray Strode for confirming the diagnosis
and providing a very elucidating test program demonstrating the problem with
dynamic loading.

For anyone's interest, the bug came about due to an optimized implementation of
the pthread interface for non-threaded applications (implemented via weak
symbols---in glibc I believe). The idea is that if the application does not
link with -lpthread then you get implementations of the pthread mutex functions
that do nothing, (since no locking is needed), allowing non-threaded functions
to have no overhead.

What was happening in this bug was that cairo would call pthread_mutex_init to
intialize a mutex, (but this function would do nothing). Then, something would
dynamically load a module which would cause pthread to be linked in, (note:
someone should chase that down in GNOME to see if it's coming in needlessly).
Finally, cairo would call a now-non-NOP version of pthread_mutex_lock with the
uninitialized mutex object and things would go south.

The fix is as simple as using memcpy of PTHREAD_MUTEX_INTIALIZER rather than
using pthread_mutex_init() to initialize the mutex.

I've attached a patch to implement the fix. I've also pushed this out to
cairo's central repository so that it will be there for the (imminent!) cairo
1.4 release. See here:


Thanks again to everyone for the reports and the patience,


Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug, or are watching the QA contact.

More information about the cairo-bugs mailing list