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

Philippe Leroux lerouxp at yahoo.ca
Wed Dec 15 02:00:55 PST 2010

thanks for your answer
i could give it a try to that pixman threadsafe lib
however i'm not sure that this is the problem 

each of my drawing threads uses it's own surface to draw to,
they create a surface, a context, draws to them and saves the images
get a new data set clears the surface, draw again, save another image and so on
each thread uses independent data sets.
error always happen when two threads call to cairo stroke or fill

so unless i am missing something here, there is a bug somewhere
maybe something very tricky
it never bugs in exactly the same way
(corruption double free, corrupted double-linked list sigabrt segfault)
sometimes from libpixman, sometimes from libGL, libxcb...

what do you think? 
i've tried looking at cairo-trace... it's a big log file. i'm not sure how i can 
find some insight in it



----- Message initial ----
De : Andrea Canciani <ranma42 at gmail.com>
À : Philippe Leroux <lerouxp at yahoo.ca>
Cc : cairo <cairo at cairographics.org>
Envoyé le : Mer 15 décembre 2010, 10h 44min 15s
Objet : Re: [cairo] Re : multithreaded bug in cairo on call to cairo stroke?

On Wed, Dec 15, 2010 at 10:31 AM, Philippe Leroux <lerouxp at yahoo.ca> wrote:
> Hi cairo-community,
>  i didnt get any answers yet
> i tried with the golang community (www.golang.org)
> and i have made sure that my functions drawing to their own surface/context 
> executed on different OS threads
> and not multiplexed on one thread
> i still get the corruption, double free  error
> so i guess this is a multithread issue inside cairo
> can anyone help me out debug that one?

Currently pixman requires that the same image is only used
in one thread at a time. Cairo, instead, assumes that an image
can be used as source in multiple threads.

Adding atomic refcounting to pixman images would likely
solve this issue.
In http://lists.cairographics.org/archives/pixman/2010-October/000644.html
you can find a link to one of my pixman branches that add atomic refcounting.

If recompiling pixman is not an option, now I'm afraid that the only way to have
a threadsafe app is not use cairo concurrently.

I should probably also mention that there are other independent threadsafety
issues in cairo vector backends, but they are likely unrelated to your problem.


More information about the cairo mailing list