From 165871e0fcb82f4db77ffa7d99ed7d641e677336 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Fri, 3 Oct 2025 11:28:19 +0200 Subject: [PATCH] command: fix possible crash on focus If the currently focused view has been moved to a different output but the transaction has not yet been completed, we can hit unreachable code in this function. thread 1073 panic: reached unreachable code /home/pkaplan/Software/river/river/command/view_operations.zig:100:21: 0x11752d6 in getTarget (river) unreachable; ^ /home/pkaplan/Software/river/river/command/view_operations.zig:46:22: 0x1146f36 in focusView (river) if (try getTarget( ^ /home/pkaplan/Software/river/river/command.zig:144:16: 0x11124e3 in run (river) try impl_fn(seat, args, out); ^ /home/pkaplan/Software/river/river/Seat.zig:447:16: 0x10eb00f in runCommand (river) command.run(seat, args, &out) catch |err| { ^ /home/pkaplan/Software/river/river/Seat.zig:423:24: 0x1110350 in handleMapping (river) seat.runCommand(mapping.command_args); ^ /home/pkaplan/Software/river/river/Keyboard.zig:213:47: 0x10e83b8 in wrapper (river) if (keyboard.device.seat.handleMapping(keycode, modifiers, released, xkb_state)) { ^ ???:?:?: 0x7d8f73aa051d in ??? (libwayland-server.so.0) Unwind information for `libwayland-server.so.0:0x7d8f73aa051d` was not available, trace may be incomplete ???:?:?: 0x7d8f739fecc7 in ??? (libwlroots-0.18.so) ???:?:?: 0x7d8f739d0dbb in ??? (libwlroots-0.18.so) ???:?:?: 0x7d8f73aa2111 in ??? (libwayland-server.so.0) ???:?:?: 0x7d8f73aa41f6 in ??? (libwayland-server.so.0) /home/pkaplan/Software/river/river/main.zig:139:25: 0x10715dd in main (river) server.wl_server.run(); ^ /usr/lib/zig/std/start.zig:524:37: 0x107083e in main (river) const result = root.main() catch |err| { ^ ???:?:?: 0x7d8f736b06b4 in ??? (libc.so.6) ???:?:?: 0x7d8f736b0768 in ??? (libc.so.6) ???:?:?: 0x1070354 in ??? (???) --- river/command/view_operations.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/river/command/view_operations.zig b/river/command/view_operations.zig index 82e2516..3f8a214 100644 --- a/river/command/view_operations.zig +++ b/river/command/view_operations.zig @@ -78,6 +78,7 @@ fn getTarget(seat: *Seat, direction_str: []const u8, target_mode: TargetMode) !? if (seat.focused.view.pending.fullscreen) return null; if (target_mode == .skip_float and seat.focused.view.pending.float) return null; const output = seat.focused_output orelse return null; + if (seat.focused.view.pending.output != output) return null; // Logical direction, based on the view stack. if (std.meta.stringToEnum(Direction, direction_str)) |direction| {