Crash in wlr_keyboard_set_keymap with no keymap
Regressed by e725f234. Missed on CI due to lack of libinput
in WLR_BACKENDS
?
$ cc --version
FreeBSD clang version 16.0.3 (https://github.com/llvm/llvm-project.git llvmorg-16.0.3-0-gda3cd333bea5)
Target: x86_64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin
$ git clone https://github.com/xkbcommon/libxkbcommon subprojects/libxkbcommon
$ meson setup --default-library=static --buildtype=debug --force-fallback-for=libxkbcommon _build
$ meson compile -C _build
$ env -i HOME=$HOME XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR WAYLAND_DISPLAY=$WAYLAND_DISPLAY lldb _build/tinywl/tinywl
[...]
00:00:00.116 [backend/wayland/backend.c:427] Starting Wayland backend
Process 45066 stopped
* thread #1, name = 'tinywl', stop reason = signal SIGSEGV: invalid address (fault address: 0x8)
frame #0: 0x00000000002edcac tinywl`xkb_keymap_ref(keymap=0x0000000000000000) at keymap.c:61:19
58 XKB_EXPORT struct xkb_keymap *
59 xkb_keymap_ref(struct xkb_keymap *keymap)
60 {
-> 61 keymap->refcnt++;
^
62 return keymap;
63 }
64
(lldb) f 2
frame #2: 0x00000000002dd0a5 tinywl`wlr_keyboard_set_keymap(kb=0x00000008448b7028, keymap=0x0000000864608c00) at wlr_keyboard.c:192:32
189 return true;
190 }
191
-> 192 struct xkb_state *xkb_state = xkb_state_new(kb->keymap);
^
193 if (xkb_state == NULL) {
194 wlr_log(WLR_ERROR, "Failed to create XKB state");
195 return false;
(lldb) bt
* thread #1, name = 'tinywl', stop reason = signal SIGSEGV: invalid address (fault address: 0x8)
* frame #0: 0x00000000002edcac tinywl`xkb_keymap_ref(keymap=0x0000000000000000) at keymap.c:61:19
frame #1: 0x000000000030e63b tinywl`xkb_state_new(keymap=0x0000000000000000) at state.c:594:19
frame #2: 0x00000000002dd0a5 tinywl`wlr_keyboard_set_keymap(kb=0x00000008448b7028, keymap=0x0000000864608c00) at wlr_keyboard.c:192:32
frame #3: 0x0000000000268853 tinywl`server_new_keyboard(server=0x00000008212e5ac8, device=0x00000008448b7028) at tinywl.c:254:2
frame #4: 0x0000000000267aea tinywl`server_new_input(listener=0x00000008212e5bb0, data=0x00000008448b7028) at tinywl.c:290:3
frame #5: 0x000000082376006c libwayland-server.so.0`wl_signal_emit_mutable + 124
frame #6: 0x00000000002afb95 tinywl`new_input_reemit(listener=0x000000084487d010, data=0x00000008448b7028) at backend.c:155:2
frame #7: 0x000000082376006c libwayland-server.so.0`wl_signal_emit_mutable + 124
frame #8: 0x00000000002b50fa tinywl`init_seat_keyboard(seat=0x00000008448b7000) at seat.c:115:2
frame #9: 0x00000000002b0b4b tinywl`backend_start(backend=0x00000008448a7000) at backend.c:434:4
frame #10: 0x0000000000282a0d tinywl`wlr_backend_start(backend=0x00000008448a7000) at backend.c:56:10
frame #11: 0x00000000002afdfe tinywl`multi_backend_start(wlr_backend=0x0000000844876000) at backend.c:31:8
frame #12: 0x0000000000282a0d tinywl`wlr_backend_start(backend=0x0000000844876000) at backend.c:56:10
frame #13: 0x00000000002672ca tinywl`main(argc=1, argv=0x00000008212e5d18) at tinywl.c:982:7
frame #14: 0x000000083159f1ca libc.so.7`__libc_start1(argc=1, argv=0x00000008212e5d18, env=0x00000008212e5d28, cleanup=<unavailable>, mainX=(tinywl`main at tinywl.c:818)) at libc_start1.c:155:7
frame #15: 0x0000000000266d02 tinywl`_start(ap=<unavailable>, cleanup=<unavailable>) at crt1_c.c:52:2
Edited by Jan Beich