9536f6a
From e912742c1e26ef853064ddf672d990e1db254492 Mon Sep 17 00:00:00 2001
9536f6a
From: Olivier Fourdan <ofourdan@redhat.com>
9536f6a
Date: Fri, 21 Oct 2016 10:11:45 +0200
9536f6a
Subject: [PATCH xserver v2] xwayland: Activate and enable touch devices
9536f6a
9536f6a
On some random condition, a touch event may trigger a crash in Xwayland
9536f6a
in GetTouchEvents().
9536f6a
9536f6a
The (simplified) backtrace goes as follow:
9536f6a
9536f6a
 (gdb) bt
9536f6a
 #0  GetTouchEvents() at getevents.c:1892
9536f6a
 #1  QueueTouchEvents() at getevents.c:1866
9536f6a
 #2  xwl_touch_send_event() at xwayland-input.c:652
9536f6a
 #5  wl_closure_invoke() from libwayland-client.so.0
9536f6a
 #6  dispatch_event() from libwayland-client.so.0
9536f6a
 #7  wl_display_dispatch_queue_pending() from libwayland-client.so.0
9536f6a
 #8  xwl_read_events() at xwayland.c:483
9536f6a
 #9  ospoll_wait() at ospoll.c:412
9536f6a
 #10 WaitForSomething() at WaitFor.c:222
9536f6a
 #11 Dispatch() at dispatch.c:412
9536f6a
 #12 dix_main() at main.c:287
9536f6a
 #13 __libc_start_main() at libc-start.c:289
9536f6a
 #14 _start ()
9536f6a
9536f6a
The crash occurs when trying to access the sprite associated with the
9536f6a
touch device, which appears to be NULL. Reason being the device itself
9536f6a
is more a keyboard device than a touch device.
9536f6a
9536f6a
Moreover, it appears the device is neither enabled nor activated
9536f6a
(inited=0, enabled=0) which doesn't seem right, but matches the code in
9536f6a
init_touch() from xwayland-input.c which would enable the device if it
9536f6a
was previously existing and otherwise would create the device but not
9536f6a
activate it.
9536f6a
9536f6a
Make sure we do activate and enable touch devices just like we do for
9536f6a
other input devices such as keyboard and pointer.
9536f6a
9536f6a
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
9536f6a
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
9536f6a
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
9536f6a
---
9536f6a
 hw/xwayland/xwayland-input.c | 7 ++++---
9536f6a
 1 file changed, 4 insertions(+), 3 deletions(-)
9536f6a
9536f6a
diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
9536f6a
index 1991076..7ec3b1a 100644
9536f6a
--- a/hw/xwayland/xwayland-input.c
9536f6a
+++ b/hw/xwayland/xwayland-input.c
9536f6a
@@ -1059,12 +1059,13 @@ init_touch(struct xwl_seat *xwl_seat)
9536f6a
     wl_touch_add_listener(xwl_seat->wl_touch,
9536f6a
                           &touch_listener, xwl_seat);
9536f6a
 
9536f6a
-    if (xwl_seat->touch)
9536f6a
-        EnableDevice(xwl_seat->touch, TRUE);
9536f6a
-    else {
9536f6a
+    if (xwl_seat->touch == NULL) {
9536f6a
         xwl_seat->touch =
9536f6a
             add_device(xwl_seat, "xwayland-touch", xwl_touch_proc);
9536f6a
+        ActivateDevice(xwl_seat->touch, TRUE);
9536f6a
     }
9536f6a
+    EnableDevice(xwl_seat->touch, TRUE);
9536f6a
+
9536f6a
 }
9536f6a
 
9536f6a
 static void
9536f6a
-- 
9536f6a
2.9.3
9536f6a