From ff94ba33cd20b1f9ec837ebcbb60f78f634f8a9a Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Fri, 8 Jul 2022 11:51:41 +0300 Subject: [PATCH] compositor: fix shutdown when xwayland failed to start This patch fixes the following: AddressSanitizer:DEADLYSIGNAL ================================================================= ==528956==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x7fbc5d66bdd7 bp 0x7ffd465573c0 sp 0x7ffd46557398 T0) ==528956==The signal is caused by a WRITE memory access. ==528956==Hint: address points to the zero page. #0 0x7fbc5d66bdd7 in wl_list_remove ../../git/wayland/src/wayland-util.c:56 #1 0x7fbc5cb8869e in wxw_compositor_destroy ../../git/weston/compositor/xwayland.c:357 #2 0x7fbc5baf3ca6 in weston_signal_emit_mutable ../../git/weston/shared/signal.c:62 #3 0x7fbc5ba4d6f9 in weston_compositor_destroy ../../git/weston/libweston/compositor.c:8639 #4 0x7fbc5cb7a5f2 in wet_main ../../git/weston/compositor/main.c:3772 #5 0x55bd13de2179 in main ../../git/weston/compositor/executable.c:33 #6 0x7fbc5be61d09 in __libc_start_main ../csu/libc-start.c:308 #7 0x55bd13de2099 in _start (/home/pq/local/bin/weston+0x1099) The problem is triggered by configuring a bad path to Xwayland in weston.ini, which causes exec() to fail. The fork() succeeded though, which means the weston_process was already on the watch list, and the watch can be handled, making sigchl_handler() leave the link uninitialized. Making sure the link remains removable fixes this. Fixes: 18897253d44449fadb1307a57eac7f4d203f3764 Signed-off-by: Pekka Paalanen --- compositor/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compositor/main.c b/compositor/main.c index 2f014404..67a90e21 100644 --- a/compositor/main.c +++ b/compositor/main.c @@ -357,6 +357,7 @@ sigchld_handler(int signal_number, void *data) } wl_list_remove(&p->link); + wl_list_init(&p->link); p->cleanup(p, status); }