From 1c51ae3de1cf26d876339d28ea3b58a25ae9bb0c Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Sun, 17 Mar 2024 20:51:29 +0000 Subject: [PATCH] xwayland: fix segv bug when starting game (threadid=, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44 at pthread_kill.c:78 (fmt=0x7739d9f9bb68 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5a76573f9222 "root", file=file@entry=0x5a76573f9606 "../labwc/src/view.c", line=line@entry=2013, function=function@entry=0x5a7657400320 <__PRETTY_FUNCTION__.14> "view_move_to_front") at assert.c:94 (assertion=assertion@entry=0x5a76573f9222 "root", file=file@entry=0x5a76573f9606 "../labwc/src/view.c", line=line@entry=2013, function=function@entry=0x5a7657400320 <__PRETTY_FUNCTION__.14> "view_move_to_front") at assert.c:103 at ../labwc/src/view.c:2013 at ../labwc/src/view-impl-common.c:30 at ../labwc/src/xwayland.c:677 at ../wayland-1.22.0/src/wayland-server.c:2241 (signal=signal@entry=0x5a7659025160, data=data@entry=0x5a7659024e90) at ../wayland-1.22.0/src/wayland-server.c:2241 at ../subprojects/wlroots/types/wlr_compositor.c:493 (cif=cif@entry=0x7ffc74d32530, fn=, rvalue=, avalue=, closure=closure@entry=0x0) at ../src/x86/ffi64.c:673 (cif=cif@entry=0x7ffc74d32530, fn=, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0x7ffc74d32600) at ../src/x86/ffi64.c:710 (closure=closure@entry=0x5a7658f5adc0, target=, target@entry=0x5a7659025240, opcode=opcode@entry=6, data=, data@entry=0x5a7658609820, flags=2) at ../wayland-1.22.0/src/connection.c:1025 (fd=, mask=, data=) at ../wayland-1.22.0/src/wayland-server.c:438 (loop=0x5a7657816e60, timeout=timeout@entry=-1) at ../wayland-1.22.0/src/event-loop.c:1027 at ../wayland-1.22.0/src/wayland-server.c:1493 at ../labwc/src/main.c:179 Reported-by: @kode54 --- src/view.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/view.c b/src/view.c index 066b8427..3b363dc4 100644 --- a/src/view.c +++ b/src/view.c @@ -2010,7 +2010,18 @@ view_move_to_front(struct view *view) } struct view *root = view_get_root(view); - assert(root); + + /* + * The case of root == NULL is unlikely, but has been reported when + * starting games on XWayland. It's believed to be caused by setting + * override-redirect on the root wlr_xwayland_surface making it not be + * associated with a view anymore. + * + * I this case we just raise the original view instead. + */ + if (!root) { + root = view; + } move_to_front(root); for_each_subview(root, move_to_front); @@ -2027,7 +2038,11 @@ view_move_to_back(struct view *view) { assert(view); struct view *root = view_get_root(view); - assert(root); + + /* See comment in view_move_to_front() */ + if (!root) { + root = view; + } for_each_subview(root, move_to_back); move_to_back(root);