[cairo] multithreaded bug in cairo on call to cairo stroke?

Andrea Canciani ranma42 at gmail.com
Fri Dec 17 06:45:49 PST 2010


On Fri, Dec 17, 2010 at 3:01 PM, Soeren Sandmann <sandmann at daimi.au.dk> wrote:
> cu <cairouser at yahoo.com> writes:
>
>> Is there a plan or an estimate as to when simpleops may become part of
>> official pixman/cairo release?
>
> While I agree that a future release of pixman should make stronger
> guarantees about thread safety, the bug here is that cairo randomly
> assumes that pixman ref counting is atomic, which it isn't and never
> was.

Yes, cairo is doing the wrong thing in this case.

>
> Just fix that bug in cairo 1.10.2 (and then don't rely on pixman
> features until pixman actually has those features).

Currently cairo has multiple issues with threadsafety, this is only
the most obvious and easy to hit. Another thread-unsafe bit is the
snapshot handling (which looks much more complicated to fix than
this one) and I'm not sure about fonts.
We should probably state that cairo 1.10 is *not* threadsafe and work
on improving threadsafety for future releases.
We could keep a list of backends which are supposed to be threadsafe,
but iirc currently both image and recording have some problems
with concurrent threads.
This also means that vector backends and fallbacks are probably
not safe (unless some very particular conditions are met).

On a side note, simpleops would also solve part of this issue if it
provided a reasonably clean way to use TLS.
If cairo caches were thread-local, we could avoid the performance
regressions caused by the removal of the caches, we would be able
to use the cached images correctly in pixman (because we would not
be using the same source in multiple threads) and the locking would
not be needed anymore.
This would probably make it possible for cairo to offer the same concurrency
guarantees as pixman (i.e. threads can't share sources or destinations), but
I might be forgetting some other issues

I believe that having the same thread guarantees in cairo and pixman
would be good, so if we want cairo to be able to use the same source in
multiple threads, we should first make it possible in pixman.

Andrea


More information about the cairo mailing list