From 01bfa2e36f7db038ddd8cacc18b5756d815ba7fb Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Wed, 24 Aug 2022 09:50:26 +0200 Subject: [PATCH] Backport upstream patch to fix a compositor crash (#2120470) --- 2592.patch | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++ mutter.spec | 9 ++++++- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 2592.patch diff --git a/2592.patch b/2592.patch new file mode 100644 index 0000000..bdc9b80 --- /dev/null +++ b/2592.patch @@ -0,0 +1,76 @@ +From ed516dde899f87b19f3dd0ed4613b692f778d437 Mon Sep 17 00:00:00 2001 +From: Carlos Garnacho +Date: Tue, 23 Aug 2022 21:56:02 +0200 +Subject: [PATCH] wayland: Add destruction listener to activation token surface + +In the timespan between an activation token being created and the +token being used by the activated application, the surface that started +the activation request may end up destroyed/disposed. + +In that case, the token would be left with a stale surface pointer, +maybe causing crashes later on. Set up a destroy notification listener +so that we do know to unset the token surface if that situation arises, +this will result in Mutter not considering the token activatable, thus +maybe issuing the "Application needs attention" notification if the +activated surface did not immediately get focus. In any case this is +better than a compositor crash. + +A typical situation where this may happen is "Open With..." dialogs, +since those don't live long after launching the application. + +Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2390 +Part-of: +--- + src/wayland/meta-wayland-activation.c | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/src/wayland/meta-wayland-activation.c b/src/wayland/meta-wayland-activation.c +index 73faa19142..b7035ab5ce 100644 +--- a/src/wayland/meta-wayland-activation.c ++++ b/src/wayland/meta-wayland-activation.c +@@ -47,6 +47,7 @@ struct _MetaXdgActivationToken + MetaWaylandSeat *seat; + MetaWaylandActivation *activation; + MetaStartupSequence *sequence; ++ struct wl_listener surface_listener; + char *app_id; + char *token; + uint32_t serial; +@@ -94,6 +95,8 @@ token_set_surface (struct wl_client *client, + MetaWaylandSurface *surface = wl_resource_get_user_data (surface_resource); + + token->surface = surface; ++ wl_resource_add_destroy_listener (surface_resource, ++ &token->surface_listener); + } + + static void +@@ -216,6 +219,17 @@ meta_xdg_activation_token_free (MetaXdgActivationToken *token) + g_free (token); + } + ++static void ++token_handle_surface_destroy (struct wl_listener *listener, ++ void *data) ++{ ++ MetaXdgActivationToken *token = wl_container_of (listener, token, ++ surface_listener); ++ ++ token->surface = NULL; ++ wl_list_remove (&token->surface_listener.link); ++} ++ + static void + meta_wayland_activation_token_create_new_resource (MetaWaylandActivation *activation, + struct wl_client *client, +@@ -237,6 +251,7 @@ meta_wayland_activation_token_create_new_resource (MetaWaylandActivation *activa + wl_resource_set_user_data (token_resource, token); + wl_list_insert (&activation->token_list, + wl_resource_get_link (token_resource)); ++ token->surface_listener.notify = token_handle_surface_destroy; + } + + static void +-- +GitLab + diff --git a/mutter.spec b/mutter.spec index db0f5c4..70c1cd9 100644 --- a/mutter.spec +++ b/mutter.spec @@ -10,7 +10,7 @@ Name: mutter Version: 43~beta -Release: 1%{?dist} +Release: 2%{?dist} Summary: Window and compositing manager based on Clutter License: GPLv2+ @@ -28,6 +28,10 @@ Patch2: mutter-42.alpha-disable-tegra.patch Patch3: 0001-build-Add-missing-include.patch +# Backported from upstream +# https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2592 +Patch4: 2592.patch + BuildRequires: pkgconfig(gobject-introspection-1.0) >= 1.41.0 BuildRequires: pkgconfig(sm) BuildRequires: pkgconfig(libwacom) @@ -171,6 +175,9 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/%{name}.desktop %{_datadir}/mutter-%{mutter_api_version}/tests %changelog +* Wed Aug 24 2022 Kalev Lember - 43~beta-2 +- Backport upstream patch to fix a compositor crash (#2120470) + * Wed Aug 10 2022 Florian Müllner - 43~beta-1 - Update to 43.beta