[Bf-blender-cvs] [8fab5809493] master: Fix T99078: Crash closing the file selector in Wayland

Campbell Barton noreply at git.blender.org
Wed Jun 22 05:12:58 CEST 2022


Commit: 8fab580949374e6208cee2e9ba2caf249bc0c1fd
Author: Campbell Barton
Date:   Wed Jun 22 13:08:55 2022 +1000
Branches: master
https://developer.blender.org/rB8fab580949374e6208cee2e9ba2caf249bc0c1fd

Fix T99078: Crash closing the file selector in Wayland

Ensure wayland handlers run that clear the window immediately after
the window has been removed so dangling pointers to the window
aren't left set.

===================================================================

M	intern/ghost/intern/GHOST_WindowWayland.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp
index 941e08ff035..01dd9721f2b 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -586,6 +586,20 @@ GHOST_WindowWayland::~GHOST_WindowWayland()
   xdg_surface_destroy(w->xdg_surface);
   wl_surface_destroy(w->wl_surface);
 
+  /* NOTE(@campbellbarton): This is needed so the appropriate handlers event
+   * (#wl_surface_listener.leave in particular) run to prevent access to the freed surfaces.
+   * Without this round-trip, calling #getCursorPosition immediately after closing a window
+   * causes dangling #wl_surface pointers to be accessed
+   * (since the window is used for scaling the cursor position).
+   *
+   * An alternative solution would be to clear all internal pointers that reference this window.
+   * Even though this is reasonable it introduces a 3rd state that needs to be accounted for,
+   * where values are cleared before they have been set to their new values.
+   * Any information requested in this state (such as the cursor position) won't be valid and
+   * could cause difficult to reproduce bugs. So perform a round-trip as closing a window isn't
+   * an action that runs continuously & isn't likely to cause unnecessary overhead. See: T99078. */
+  wl_display_roundtrip(m_system->display());
+
   delete w;
 }



More information about the Bf-blender-cvs mailing list