[cairo] assertion - locking problem in multithreaded app

Jan Slupski jslupski at gmail.com
Sat Jan 20 19:46:36 PST 2007

Hi Carl,

Carl Worth wrote:
>> I have tried the patch that is attached to the bugzilla report and it helped
>> much (after fixing it a bit - see my comment on the bottom of bugzilla),
> Thanks for the fixup. I caught that part, but I think I screwed
> something else up. When I applied the patches I started getting hangs
> with "make test". Maybe I broke things when trying to apply the
> patches, (they're not perfectly clean in bugzilla). If somebody would
> post a known-good and ready-to-apply patch that would be helpful.

I have reposted Monty's patches - both combined into one and with two 


First addition is change LOCK to UNLOCK I've been writing on before (and 
without this I've been getting deadlocks).
Another is mutex declaration and initialization to allow code to be 
compiled on win32.
Since I don't use anything beyond Linux/Unix & win32 I didn't do any 
additional changes, but probably other platforms (BeOS?) may require 
some additional code too...

>> I guess this may be related to Behdad suggestion 'This bug suggests that
>> the same is happening in cairo_ft_scaled_font_lock/unlock'.

Looking at the patch provided by Monty, I have added similar code in a 
few more places, adding total of 5 new mutex.

I'm not sure if all of them are necessary, but at least on my tests I 
couldn't reproduce crashes anymore.

Please carefully examine all of them, since I didn't have much to do 
with cairo internals before. Especially 'cairo_font_face_refcount_mutex' 
that is more tricky then others.


 >> Are there any works done to fix this. Is there anything I could do
 >> to help?
> One thing that would be nice to have is a test case suitable for the
> cairo/test that exercises these bugs as well as possible. Care to work
> up something like that?

If you feel you may still need it, I can try to prepare one.

But I suspect that key issue is way of testing. As I wrote in patch 
comment (https://bugs.freedesktop.org/show_bug.cgi?id=8801#c14), I've 
been using dual core processor, and I think that made possible that
two threads repeating the same code could hit the same block in the same 
moment (that caused the crash).


More information about the cairo mailing list