[Wayland-bugs] [Bug 91750] Wayland may have interface bug when multi-threads programing.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Aug 25 01:54:36 PDT 2015


https://bugs.freedesktop.org/show_bug.cgi?id=91750

--- Comment #5 from Pekka Paalanen <ppaalanen at gmail.com> ---
(In reply to Jonas Ã…dahl from comment #4)
> The difference to your example below is the wl_display_prepare_read(display)
> before creating the proxy, and wl_display_cancel_read(display) after setting
> the queue. The effect is that the other thread will not dispatch it, since
> it will only the dispatch events on the queue associated with it.
> 
> Now, wl_display_roundtrip_queue() is a function that currently exposes the
> bug, but I'm not sure what unforseen side effects would be to add a
> work-around like the above, and whether it is a good idea to do it. The
> obvious side effect would be stalling other dispatcher threads a bit more
> than before.
> 
> Pekka, any opinions whether we should temporarly "fix"
> wl_display_roundtrip_queue() until we introduce some new API?

It would only fix the roundtrip and none of the other problems. IMHO it would
be a wasted effort, time would be better spent solving the underlying problem.

Using wl_display_prepare_read() is problematic, because it requires the
wl_event_queue to be empty. You need a dispatch loop to drain the
wl_event_queue until prepare_read() succeeds. Maybe that is not *that* bad
since wl_display_roundtrip_queue() *is* a dispatching function.

However, wl_display_roundtrip_queue() explicitly documents itself to be
incompatible with prepare_read() because roundtrip_queue() uses
wl_display_dispatch_queue(). I really do not want to review whether we could
break that rule in this specific case or not.

Because of the above, using wl_display_roundtrip{,_queue}() in a program using
the same wl_display from multiple threads is a mistake to begin with.

All this makes me wonder if we could rewrite the roundtrip functions on top the
prepare_read() API, and just deprecate wl_display_dispatch{,_queue}()
completely. Multi-threaded programs using 
wl_display_dispatch{,_queue}() are broken to start with, and single-threaded
programs using wl_display_dispatch{,_queue}() cannot use the mutually exclusive
APIs at the same time by definition.

Yes, Mesa EGL Wayland platform implementation is broken. It uses
wl_display_dispatch_queue().

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-bugs/attachments/20150825/df29b049/attachment-0001.html>


More information about the wayland-bugs mailing list