<div dir="ltr">Hi Lyude,<br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 5, 2018 at 11:22 PM, Lyude Paul <span dir="ltr"><<a href="mailto:lyude@redhat.com" target="_blank">lyude@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Unfortunately, on my machine Xwayland immediately crashes when I try to<br>
start it. gdb backtrace:<br>
<br>
 #0  0x00007ffff74f0e79 in wl_proxy_marshal () from target:/lib64/libwayland-<wbr>client.so.0<br>
 #1  0x0000000000413172 in zwp_confined_pointer_v1_<wbr>destroy (zwp_confined_pointer_v1=<wbr>0x700000000)<br>
     at hw/xwayland/Xwayland@exe/<wbr>pointer-constraints-unstable-<wbr>v1-client-protocol.h:612<br>
 #2  0x0000000000418bc0 in xwl_seat_destroy_confined_<wbr>pointer (xwl_seat=0x8ba2a0)<br>
     at /home/lyudess/Projects/<wbr>xserver/hw/xwayland/xwayland-<wbr>input.c:2839<br>
 #3  0x0000000000418c09 in xwl_seat_unconfine_pointer (xwl_seat=0x8ba2a0)<br>
     at /home/lyudess/Projects/<wbr>xserver/hw/xwayland/xwayland-<wbr>input.c:2849<br>
 #4  0x0000000000410d97 in xwl_cursor_confined_to (device=0xa5a000, screen=0x8b9d80, window=0x9bdb70)<br>
     at /home/lyudess/Projects/<wbr>xserver/hw/xwayland/xwayland.<wbr>c:328<br>
 #5  0x00000000004a8571 in ConfineCursorToWindow (pDev=0xa5a000, pWin=0x9bdb70, generateEvents=1,<br>
     confineToScreen=0) at /home/lyudess/Projects/<wbr>xserver/dix/events.c:900<br>
 #6  0x00000000004a94b7 in ScreenRestructured (pScreen=0x8b9d80)<br>
     at /home/lyudess/Projects/<wbr>xserver/dix/events.c:1387<br>
 #7  0x0000000000502386 in RRScreenSizeNotify (pScreen=0x8b9d80)<br>
     at /home/lyudess/Projects/<wbr>xserver/randr/rrscreen.c:160<br>
 #8  0x000000000041a83c in update_screen_size (xwl_output=0x8e7670, width=3840, height=2160)<br>
     at /home/lyudess/Projects/<wbr>xserver/hw/xwayland/xwayland-<wbr>output.c:203<br>
 #9  0x000000000041a9f0 in apply_output_change (xwl_output=0x8e7670)<br>
     at /home/lyudess/Projects/<wbr>xserver/hw/xwayland/xwayland-<wbr>output.c:252<br>
 #10 0x000000000041aaeb in xdg_output_handle_done (data=0x8e7670, xdg_output=0x8e7580)<br>
     at /home/lyudess/Projects/<wbr>xserver/hw/xwayland/xwayland-<wbr>output.c:307<br>
 #11 0x00007ffff50e9d1e in ffi_call_unix64 () at ../src/x86/unix64.S:76<br>
 #12 0x00007ffff50e968f in ffi_call (cif=<optimized out>, fn=<optimized out>, rvalue=<optimized out>,<br>
     avalue=<optimized out>) at ../src/x86/ffi64.c:525<br>
 #13 0x00007ffff74f3d8b in wl_closure_invoke () from target:/lib64/libwayland-<wbr>client.so.0<br>
 #14 0x00007ffff74f0928 in dispatch_event.isra () from target:/lib64/libwayland-<wbr>client.so.0<br>
 #15 0x00007ffff74f1be4 in wl_display_dispatch_queue_<wbr>pending () from target:/lib64/libwayland-<wbr>client.so.0<br>
 #16 0x00007ffff74f200b in wl_display_roundtrip_queue () from target:/lib64/libwayland-<wbr>client.so.0<br>
 #17 0x0000000000418cad in InitInput (argc=12, argv=0x7fffffffd9c8)<br>
     at /home/lyudess/Projects/<wbr>xserver/hw/xwayland/xwayland-<wbr>input.c:2867<br>
 #18 0x00000000004a20e3 in dix_main (argc=12, argv=0x7fffffffd9c8, envp=0x7fffffffda30)<br>
     at /home/lyudess/Projects/<wbr>xserver/dix/main.c:250<br>
 #19 0x0000000000420cb2 in main (argc=12, argv=0x7fffffffd9c8, envp=0x7fffffffda30)<br>
    at /home/lyudess/Projects/<wbr>xserver/dix/stubmain.c:34<br>
<br>
This appears to be the result of xwl_cursor_confined_to() and<br>
xwl_screen_get_default_seat(). xwl_cursor_confined_to() can be called<br>
very on during the Xwayland init sequence, well before any seat has<br>
actually been created for the server. However, this function doesn't<br>
make an attempt to actually check for whether or not there's currently<br>
a seat available, and just eagerly assumes that<br>
xwl_screen_get_default_seat() will always return a valid seat.<br>
Unfortunately, before an xwl_seat is actually initialized the xorg_list<br>
will be in a fresh state with no members in it, e.g. list->prev ==<br>
list->next == &list. Since xwl_screen_get_default_seat() doesn't actually check<br>
whether or not the seat list is empty, this causes us to end up<br>
returning a pointer to &list instead of an actual xwl_seat struct, which<br>
subsequently causes us to crash.<br>
<br>
So, actually return NULL in xwl_screen_get_default_seat() if the seat<br>
list is empty, and skip any pointer confinement processing in<br>
xwl_cursor_confined_to() when we don't have a seat setup yet.<br>
<br>
Signed-off-by: Lyude Paul <<a href="mailto:lyude@redhat.com">lyude@redhat.com</a>><br>
---<br>
Just a quick note!!! I haven't actually tested at all whether or not<br>
this breaks cursor confinement, if you have any demo applications I use<br>
to easily do this please let me know. I have at least, tested that this<br>
lets me start Xwayland again :).<br>
<br>
 hw/xwayland/xwayland.c | 7 +++++++<br>
 1 file changed, 7 insertions(+)<br>
<br>
diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c<br>
index 19aa14a47..9b1d85674 100644<br>
--- a/hw/xwayland/xwayland.c<br>
+++ b/hw/xwayland/xwayland.c<br>
@@ -265,6 +265,9 @@ xwl_close_screen(ScreenPtr screen)<br>
 static struct xwl_seat *<br>
 xwl_screen_get_default_seat(<wbr>struct xwl_screen *xwl_screen)<br>
 {<br>
+    if (xorg_list_is_empty(&xwl_<wbr>screen->seat_list))<br>
+        return NULL;<br>
+<br>
     return container_of(xwl_screen->seat_<wbr>list.prev,<br>
                         struct xwl_seat,<br>
                         link);<br>
@@ -324,6 +327,10 @@ xwl_cursor_confined_to(<wbr>DeviceIntPtr device,<br>
     if (!xwl_seat)<br>
         xwl_seat = xwl_screen_get_default_seat(<wbr>xwl_screen);<br>
<br>
+    /* xwl_seat hasn't been setup yet, don't do anything just yet */<br>
+    if (!xwl_seat)<br>
+        return;<br>
+<br>
     if (window == screen->root) {<br>
         xwl_seat_unconfine_pointer(<wbr>xwl_seat);<br>
         return;<br>
<span class="gmail-HOEnZb"><font color="#888888">--<br>
2.14.3<br>
<br>
______________________________<wbr>_________________<br>
<a href="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</a>: X.Org development<br>
Archives: <a href="http://lists.x.org/archives/xorg-devel" rel="noreferrer" target="_blank">http://lists.x.org/archives/<wbr>xorg-devel</a><br>
Info: <a href="https://lists.x.org/mailman/listinfo/xorg-devel" rel="noreferrer" target="_blank">https://lists.x.org/mailman/<wbr>listinfo/xorg-devel</a></font></span></blockquote></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">Looks like the compositor (gnome-shell/mutter) is sending xdg_output before wl_seat (which is legit, but overlooked in Xwayland).</div><div class="gmail_extra"><br></div><div class="gmail_extra">I agree with the patch but I'd rather have that root cause mentioned in the commit message instead.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Cheers,</div><div class="gmail_extra">Olivier<br></div></div>