xwayland-input: Fix a crasher for a race with the Wayland compositor

If something quickly maps and unmaps a window, then we'll immediately
create and destroy the Wayland surface that cooresponds to that
window. If our mouse pointer is over the window when the surface is
created, we'll receive a enter on the window.

Since resource creation and destruction is not synchronous, that
means that the compositor will queue up an event for a resource that's
eventually destroyed. On the client-side, when we receive this message,
we note that the resource isn't allocated, and get a NULL surface in our
enter handler. We immediately try to dereference this, and then crash.

This was caused by running gtkperf while moving the window a lot.

Reviewed-by: Daniel Stone <daniel@fooishbar.org>
Signed-off-by: Jasper St. Pierre <jstpierre@mecheye.net>
This commit is contained in:
Jasper St. Pierre 2014-06-30 15:28:16 -04:00
parent 1d32004ed5
commit 6c442fc4f7

View File

@ -152,6 +152,15 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
ScreenPtr pScreen = xwl_seat->xwl_screen->screen;
ValuatorMask mask;
/* There's a race here where if we create and then immediately
* destroy a surface, we might end up in a state where the Wayland
* compositor sends us an event for a surface that doesn't exist.
*
* Don't process enter events in this case.
*/
if (surface == NULL)
return;
xwl_seat->xwl_screen->serial = serial;
xwl_seat->pointer_enter_serial = serial;