pango-win32 thread safety problems
Submitted by Erick Jones
Link to original bug (#765246)
Description
Created attachment 326305 Multi-threaded test (Qt application)
I have a large-scale Win32-based project that uses Pango from multiple threads. We've recently been seeing a lot of crash reports that seem to be the result of two of these threads running Pango routines concurrently. It has us wondering if Pango is really threadsafe, but from other tickets I've seen here, it sounds like it's supposed to be.
I've tried to create as simple a test case as possible. Attached is a Qt GUI program, which shows four panels simultaneously animating an image based on the basic example at https://developer.gnome.org/pango/unstable/pango-Cairo-Rendering.html. If the routine generating these images is allowed to overlap itself on separate threads, then the characters all display as missing-symbol glyphs (rectangles), and I get this message repeatedly in the console:
Pango-WARNING **: All font fallbacks failed!!!!
The program can be adjusted to only run one worker thread, or to wrap the Pango work in a mutex (see main.h). Either modification eliminates the problem.
I only get this problem in Windows. If I run this same program in Linux -- even with multiple threads and no mutex -- everything displays correctly and I get no warning messages.
Note that the actual Pango code is self-contained in a single routine (DisplayTextCircle). It deletes the cairo_t and cairo_surface_t that it creates before returning, so these resources are definitely not being shared between threads.
See README.txt for notes on building/running the project. And please let me know if there's something I need to do differently to make this easier to look at.
Attachment 326305, "Multi-threaded test (Qt application)":
pango_threadsafe_test.tar.xz
Version: 1.39.x