Revert "xwayland: Call register_damage depending on ensure_surface_for_window"

There've been reports downstream of Xwayland segfaulting in the function
xwl_present_execute() because xwl_window_get_damage_region() returned an
invalid pointer:

 #10 RegionUninit at ../include/regionstr.h:165
 #11 RegionEmpty at ../include/regionstr.h:194
 #12 xwl_present_execute at ../hw/xwayland/xwayland-present.c:1138
 #13 xwl_present_pixmap at ../hw/xwayland/xwayland-present.c:1274
 #14 present_pixmap at ../present/present.c:249
 #15 proc_present_pixmap_common at ../present/present_request.c:166
 #16 proc_present_pixmap at ../present/present_request.c:186
 #17 Dispatch at ../dix/dispatch.c:550
 #18 dix_main at ../dix/main.c:277

The most likely reason for this is that window_get_damage() returned
NULL, which might happen if xwl_window_update_surface_window() didn't
call register_damage().

To avoid that issue, move the call to register_damage() back to
xwl_realize_window before calling ensure_surface_for_window().

This reverts commit 07f6032627.

See-also: https://bugzilla.redhat.com/2329815
See-also: https://bugzilla.redhat.com/2428249
Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1862
Signed-off-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2135>
This commit is contained in:
Michel Dänzer 2024-12-24 16:01:48 +01:00 committed by Olivier Fourdan
parent 0472d7389e
commit c76d495612

View file

@ -1627,14 +1627,18 @@ xwl_realize_window(WindowPtr window)
}
}
if (xwl_screen->rootless ?
(window->drawable.class == InputOutput &&
window->parent == window->drawable.pScreen->root) :
!window->parent) {
if (!register_damage(window))
return FALSE;
}
xwl_window = ensure_surface_for_window(window);
if (!xwl_window)
return FALSE;
if (window == xwl_window->surface_window &&
!window_get_damage(window))
return register_damage(window);
return TRUE;
}