mutter/src/backends/x11
Jonas Ådahl e5ea8f5483 stage/x11: Check that message is WM_PROTOCOLS before assuming so
When a touch sequence was rejected, we'd update the event timestamps of
incoming touch events to help with implementing grabs. This was done by
sending a ClientMessage with a counter, and comparing the counter to
decide whether we're seing a replayed event or not.

This had the unforseen consequence that we would potentially end up
destroying all actors including the stage, since, when mutter receives a
ClientMessage event, it would assume that it's a WM_PROTOCOLS event, and
handle it as such. The problem with this approach is that it would
ignore fact that there might be other ClientMessage types sent to it,
for example the touch synchronization one. What could happen is that the
touch count value would match up with the value of the WM_DELETE_WINDOW
atom, clutter would treat this as WM_PROTOCOLS:WM_DELETE_WINDOW, which
it'd translate to clutter_actor_destroy(stage).

Destroying the stage in such a way is not expected, and caused wierd
crashes in different places depending on what was going on.

This commit make sure we only treat WM_PROTOCOLS client messages as
WM_PROTOCOLS client messages effectively avoiding the issue.

This fixes crashes such as:

 #0  meta_window_get_buffer_rect (window=0x0, rect=rect@entry=0x7ffd7fc62e40) at core/window.c:4396
 #1  0x00007f1e2634837f in get_top_visible_window_actor (compositor=0x297d700, compositor=0x297d700) at compositor/compositor.c:1059
 #2  meta_compositor_sync_stack (compositor=0x297d700, stack=<optimized out>, stack@entry=0x26e3140) at compositor/compositor.c:1176
 #3  0x00007f1e263757ac in meta_stack_tracker_sync_stack (tracker=0x297dbc0) at core/stack-tracker.c:871
 #4  0x00007f1e26375899 in stack_tracker_sync_stack_later (data=<optimized out>) at core/stack-tracker.c:881
 #5  0x00007f1e26376914 in run_repaint_laters (laters_list=0x7f1e2663b7d8 <laters+24>) at core/util.c:809
 #6  run_all_repaint_laters (data=<optimized out>) at core/util.c:826
 #7  0x00007f1e26b18325 in _clutter_run_repaint_functions (flags=flags@entry=CLUTTER_REPAINT_FLAGS_PRE_PAINT) at clutter-main.c:3448
 #8  0x00007f1e26b18fc5 in master_clock_update_stages (master_clock=0x32d6a80, stages=0x4e5a740) at clutter-master-clock-default.c:437
 #9  clutter_clock_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at clutter-master-clock-default.c:567
 #10 0x00007f1e27e48049 in g_main_dispatch (context=0x225b8d0) at gmain.c:3175
 #11 g_main_context_dispatch (context=context@entry=0x225b8d0) at gmain.c:3828
 #12 0x00007f1e27e483a8 in g_main_context_iterate (context=0x225b8d0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3901
 #13 0x00007f1e27e4867a in g_main_loop_run (loop=0x24e29f0) at gmain.c:4097
 #14 0x00007f1e2636a3dc in meta_run () at core/main.c:666
 #15 0x000000000040219c in main (argc=1, argv=0x7ffd7fc63238) at ../src/main.c:534

and

 #0  0x00007f93943c1f25 in raise () at /usr/lib/libc.so.6
 #1  0x00007f93943ab897 in abort () at /usr/lib/libc.so.6
 #2  0x00007f9393e1e062 in g_assertion_message (domain=<optimized out>, file=<optimized out>, line=<optimized out>, func=0x7f93933e6860 <__func__.116322> "meta_x11_get_stage_window",
 #3  0x00007f9393e4ab1d in g_assertion_message_expr ()
 #4  0x00007f939338ecd7 in meta_x11_get_stage_window (stage=<optimized out>) at ../mutter/src/backends/x11/meta-stage-x11.c:923
 #5  0x00007f939339e599 in meta_backend_x11_cm_translate_device_event (x11=<optimized out>, device_event=0x55bc8bcfd6b0) at ../mutter/src/backends/x11/cm/meta-backend-x11-cm.c:381
 #6  0x00007f939339f2e2 in meta_backend_x11_translate_device_event (device_event=0x55bc8bcfd6b0, x11=0x55bc89dd5220) at ../mutter/src/backends/x11/meta-backend-x11.c:179
 #7  0x00007f939339f2e2 in translate_device_event (device_event=0x55bc8bcfd6b0, x11=0x55bc89dd5220) at ../mutter/src/backends/x11/meta-backend-x11.c:208
 #8  0x00007f939339f2e2 in maybe_spoof_event_as_stage_event (input_event=0x55bc8bcfd6b0, x11=0x55bc89dd5220) at ../mutter/src/backends/x11/meta-backend-x11.c:284
 #9  0x00007f939339f2e2 in handle_input_event (event=0x7fff62d60490, x11=0x55bc89dd5220) at ../mutter/src/backends/x11/meta-backend-x11.c:309
 #10 0x00007f939339f2e2 in handle_host_xevent (event=0x7fff62d60490, backend=0x55bc89dd5220) at ../mutter/src/backends/x11/meta-backend-x11.c:413
 #11 0x00007f939339f2e2 in x_event_source_dispatch (source=<optimized out>, callback=<optimized out>, user_data=<optimized out>) at ../mutter/src/backends/x11/meta-backend-x11.c:467
 #12 0x00007f9393e6c39e in g_main_dispatch (context=0x55bc89dd03e0) at ../glib/glib/gmain.c:3179
 #13 0x00007f9393e6c39e in g_main_context_dispatch (context=context@entry=0x55bc89dd03e0) at ../glib/glib/gmain.c:3844
 #14 0x00007f9393e6e1b1 in g_main_context_iterate (context=0x55bc89dd03e0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/glib/gmain.c:3917
 #15 0x00007f9393e6f0c3 in g_main_loop_run (loop=0x55bc8a042640) at ../glib/glib/gmain.c:4111
 #16 0x00007f9393369a0c in meta_run () at ../mutter/src/core/main.c:676
 #17 0x000055bc880f2426 in main (argc=<optimized out>, argv=<optimized out>) at ../gnome-shell/src/main.c:552

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/338
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/951

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1317
2020-06-16 13:59:15 +00:00
..
cm cursor-renderer: Pass backend to constructor 2020-06-05 21:39:27 +00:00
nested crtc: Move MetaCrtcConfig field to instance private 2020-06-10 18:54:50 +00:00
meta-backend-x11.c compositor: use XDG_CONFIG_HOME as initial lookup path for xkb 2020-06-08 11:29:30 +00:00
meta-backend-x11.h Clean up include macros mess 2018-11-06 17:17:36 +01:00
meta-barrier-x11.c Use G_DECLARE_DERIVABLE/FINAL_TYPE on some types 2018-12-21 19:48:50 +00:00
meta-barrier-x11.h Use G_DECLARE_DERIVABLE/FINAL_TYPE on some types 2018-12-21 19:48:50 +00:00
meta-clutter-backend-x11.c clutter: Drop ClutterDeviceManager 2020-01-30 18:11:23 +01:00
meta-clutter-backend-x11.h Make mutter manage its own clutter backends 2016-07-20 14:23:48 +08:00
meta-crtc-xrandr.c backends-x11: Remove g_new0 overwriting g_object_new 2020-06-11 07:53:02 +00:00
meta-crtc-xrandr.h crtc: Make implementations inherit MetaCrtc 2020-06-10 18:54:51 +00:00
meta-cursor-renderer-x11.c Clean up include macros mess 2018-11-06 17:17:36 +01:00
meta-cursor-renderer-x11.h Clean up include macros mess 2018-11-06 17:17:36 +01:00
meta-event-x11.c event-x11: Use CLUTTER prefix for X11 filter docs 2019-10-10 13:00:02 +00:00
meta-event-x11.h clutter: Move X11 input to src/backends/x11 2019-08-24 08:59:08 +00:00
meta-gpu-xrandr.c crtc-mode: Move away fields from public MetaCrtcMode struct 2020-06-10 18:54:51 +00:00
meta-gpu-xrandr.h backend: Move GPU ownership from the monitor manager to the backend 2019-06-20 13:31:55 +00:00
meta-input-device-tool-x11.c clutter: Move X11 input to src/backends/x11 2019-08-24 08:59:08 +00:00
meta-input-device-tool-x11.h clutter: Move X11 input to src/backends/x11 2019-08-24 08:59:08 +00:00
meta-input-device-x11.c backends/x11: Fix access to WacomDevice 2020-04-07 17:36:13 +00:00
meta-input-device-x11.h backends: Add MetaInputDevice derivable class 2020-03-24 18:07:31 +00:00
meta-input-settings-x11.c input-settings/x11: Fix typo in has_udev_property 2020-03-15 13:04:32 +09:00
meta-input-settings-x11.h Clean up include macros mess 2018-11-06 17:17:36 +01:00
meta-keymap-x11.c clutter: Move keymap from ClutterBackend to ClutterSeat 2020-01-30 17:59:47 +01:00
meta-keymap-x11.h clutter: Move keymap direction from ClutterBackend to ClutterKeymap 2020-01-30 17:59:46 +01:00
meta-monitor-manager-xrandr.c crtc-mode: Move away fields from public MetaCrtcMode struct 2020-06-10 18:54:51 +00:00
meta-monitor-manager-xrandr.h Clean up include macros mess 2018-11-06 17:17:36 +01:00
meta-output-xrandr.c crtc-mode: Move away fields from public MetaCrtcMode struct 2020-06-10 18:54:51 +00:00
meta-output-xrandr.h output: Make implementations inherit MetaOutput 2020-06-10 18:54:51 +00:00
meta-renderer-x11.c cogl: Remove GLX "threaded swap wait" used on Nvidia 2019-09-02 18:12:10 +08:00
meta-renderer-x11.h renderer-x11: Split up into CM and Nested renderers 2017-04-07 22:30:49 +08:00
meta-seat-x11.c clutter/seat: Add private method to peek list of input devices 2020-06-16 10:09:26 +00:00
meta-seat-x11.h clutter: Drop select_stage_events() device manager vfunc 2020-01-30 18:02:34 +01:00
meta-stage-x11.c stage/x11: Check that message is WM_PROTOCOLS before assuming so 2020-06-16 13:59:15 +00:00
meta-stage-x11.h stage-x11: Move view management to renderer 2020-05-22 00:15:48 +00:00
meta-virtual-input-device-x11.c clutter: Move keymap from ClutterBackend to ClutterSeat 2020-01-30 17:59:47 +01:00
meta-virtual-input-device-x11.h clutter: Move X11 input to src/backends/x11 2019-08-24 08:59:08 +00:00
meta-xkb-a11y-x11.c clutter: Move keyboard a11y from ClutterDeviceManager to ClutterSeat 2020-01-30 18:01:50 +01:00
meta-xkb-a11y-x11.h clutter: Move keyboard a11y from ClutterDeviceManager to ClutterSeat 2020-01-30 18:01:50 +01:00