Crash when calling Weston/Cairo drawing functions from multiple threads

Pekka Paalanen pekka.paalanen at haloniitty.fi
Thu Mar 6 09:19:29 UTC 2025


On Wed, 5 Mar 2025 21:45:54 -0500
Bill Hayden <hayden at haydentech.com> wrote:

> I am porting a multi-threaded UI toolkit to Weston (layered on top of
> toytoolkit), and running into an issue.  This UI toolkit expects to be able
> to draw from multiple threads, to be specific, from a different thread than
> the one that called display_run() -- i.e. not from a
> widget_redraw_handler_t function or the like.

Hi Bill,

the toytoolkit is a toy of a toolkit, not intended for serious use. It
is inherently not thread-safe at all.


Sorry,
pq

> 
> Just a single call to widget_cairo_create() from another thread, even if
> nothing is done with the returned context, is enough to trigger a crash.
> The crash always manifests the same way: leaf->cairo_surface is NULL in
> shm_surface_swap(), resulting in cairo_image_surface_get_width() triggering
> a segfault.
> 
> The call stack looks like this:
> cairo_image_surface_get_width
> shm_surface_swap
> surface_flush
> window_flush
> run_deferred_tasks
> <display loop function>
> 
> Any help would be appreciated!

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20250306/d286e991/attachment.sig>


More information about the wayland-devel mailing list