talking in #cairo on IRC, sanooj came up with this patch:
which fixed the problem
This is a patch against cairo, although atomic ref counting would be useful in pixman too.
Søren, the patch is irrelevant. It just highlights how Cairo needs atomic refcounting on pixman_image_t, without which the alternative is such a monstrosity.
The solution lies within pixman.
Here's a patch that removes the need for atomic pixman_image_ref()/unref() in cairo, mostly by dropping the global solid colour cache:
I really think the bug should be flagged as still open.
Adding atomic refcounting would be fairly easy using GCC builtins. See http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html
Fixed in cairo master.
Author: M Joonas Pihlaja <email@example.com>
Date: Sat Feb 19 17:46:45 2011 +0200
image: Avoid reusing pixman images for threadsafety.