I have one DP1.2 monitor that includes a HUB, which allows me to "daisy-chain" a second screen.
SNIP /sys/kernel/debug/dri/0/i915_display_info
connector 79: type DP-2, status: disconnected
DPCD rev: 12
audio support: no
DP branch device present: yes
Type: DisplayPort
ID: Dp1.2
HW: 0.0
SW: 0.21
modes:
This gives me two additional connectors, DP-5 and DP-6.
SNIP /sys/kernel/debug/dri/0/i915_display_info
connector 120: type DP-5, status: connected
name:
physical dimensions: 640x400mm
subpixel order: Unknown
CEA rev: 3
audio support: yes
connector 151: type DP-6, status: connected
name:
physical dimensions: 520x320mm
subpixel order: Unknown
CEA rev: 3
audio support: yes
Whenever I turn off the "main" monitor, both of them get disconnected, once I power it on, both get connected at the same time, which results with the following coredump (100% reproduction):
gdb coredump
Core was generated by `sway'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x0000000000423521 in seat_get_focused_workspace (seat=0xe5e9b0) at ../sway/input/seat.c:965
965 if (focus->type == N_CONTAINER) {
(gdb) bt
#0 0x0000000000423521 in seat_get_focused_workspace (seat=0xe5e9b0) at ../sway/input/seat.c:965
#1 0x0000000000447226 in workspace_by_name (name=0x12585a0 "1:q") at ../sway/tree/workspace.c:291
#2 0x0000000000446dd9 in workspace_name_from_binding (binding=0xe9a620, output_name=0x105ef00 "DP-5", min_order=0x7ffc94ea1dec, earliest_name=0x7ffc94ea1de0) at ../sway/tree/workspace.c:202
#3 0x0000000000446f40 in workspace_next_name (output_name=0x105ef00 "DP-5") at ../sway/tree/workspace.c:238
#4 0x00000000004489d5 in output_enable (output=0x12b7930, oc=0xe4cde0) at ../sway/tree/output.c:81
#5 0x0000000000418890 in handle_new_output (listener=0x666b18 <server+56>, data=0x105eed0) at ../sway/desktop/output.c:552
#6 0x0000146e8e935441 in wlr_signal_emit_safe (signal=0x804fc8, data=0x105eed0) at ../util/signal.c:29
#7 0x0000146e8e8f9316 in new_output_reemit (listener=0x9883f8, data=0x105eed0) at ../backend/multi/backend.c:120
#8 0x0000146e8e935441 in wlr_signal_emit_safe (signal=0x80efb8, data=0x105eed0) at ../util/signal.c:29
#9 0x0000146e8e8f22f2 in scan_drm_connectors (drm=0x80ef90) at ../backend/drm/drm.c:1124
#10 0x0000146e8e8ede94 in drm_invalidated (listener=0x80f070, data=0x805030) at ../backend/drm/backend.c:118
#11 0x0000146e8e935441 in wlr_signal_emit_safe (signal=0x7fdc10, data=0x805030) at ../util/signal.c:29
#12 0x0000146e8e8fa116 in udev_event (fd=6, mask=1, data=0x805030) at ../backend/session/session.c:51
#13 0x0000146e8eb6f9b2 in wl_event_loop_dispatch (loop=0x7fcf40, timeout=timeout@entry=-1) at src/event-loop.c:641
#14 0x0000146e8eb6e70a in wl_display_run (display=0x7ff500) at src/wayland-server.c:1260
#15 0x0000000000415785 in server_run (server=0x666ae0 <server>) at ../sway/server.c:165
#16 0x0000000000414f53 in main (argc=1, argv=0x7ffc94ea2638) at ../sway/main.c:384
(gdb) l
960 struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat) {
961 struct sway_node *focus = seat_get_focus(seat);
962 if (!focus) {
963 return NULL;
964 }
965 if (focus->type == N_CONTAINER) {
966 return focus->sway_container->workspace;
967 }
968 if (focus->type == N_WORKSPACE) {
969 return focus->sway_workspace;
(gdb) p focus
$1 = (struct sway_node *) 0x1
If I turn off the second display, and turn on it after the first one gets connected, so we have one connector getting up at a time, everything works as expected.
Can you test this out with rootston, and if it also fails, move the ticket to https://github.com/swaywm/wlroots?
The stack trace is within sway, so it's unlikely the issue is about wlroots. It seems that the focus stack gets corrupted somehow? I think this is related to #2714.
dur, it helps to read
Looking at set_get_focused_workspace, it's not immediately obvious how that can fail on that line. I suspect the focus stack is empty and we're reading garbage data from it.
@ivyl Can you please try with the following?
diff --git a/sway/input/seat.c b/sway/input/seat.c
index e10b6409..69bee47e 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -952,6 +952,9 @@ struct sway_node *seat_get_focus(struct sway_seat *seat) {
if (!seat->has_focus) {
return NULL;
}
+ if (wl_list_length(&seat->focus_stack) == 0) {
+ return NULL;
+ }
struct sway_seat_node *current =
wl_container_of(seat->focus_stack.next, current, link);
return current->node;
@ivyl Can you please try with the following?
Indeed, I did some poking around inside the coredump and the list seems to be empty. After adding the sanity check you have proposed, sway does no longer crash the same way, although it is still far from handling DisplayPort hubs gracefully.
After about 20 power cycles of the main monitor:
a) all graphic applications just die, including swaylock
b) sometimes one of the outputs does not get up and remains blank
c) swaybg segfaults all the time
Core was generated by `swaybg 0 /home/ahiler/pictures/n0x244u8ajez.png fill'.
Program terminated with signal SIGABRT, Aborted.
#0 0x000014da033c6eab in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x000014da033c6eab in raise () at /lib64/libc.so.6
#1 0x000014da033b15b9 in abort () at /lib64/libc.so.6
#2 0x000014da033b1491 in _nl_load_domain.cold.0 () at /lib64/libc.so.6
#3 0x000014da033bf612 in () at /lib64/libc.so.6
#4 0x0000000000402d99 in main (argc=4, argv=0x7ffe092456a8) at ../swaybg/main.c:230
(gdb) f 4
#4 0x0000000000402d99 in main (argc=4, argv=0x7ffe092456a8) at ../swaybg/main.c:230
230 assert(state.compositor && state.layer_shell && state.output && state.shm);
(gdb) l
225 assert(state.display);
226
227 struct wl_registry *registry = wl_display_get_registry(state.display);
228 wl_registry_add_listener(registry, ®istry_listener, &state);
229 wl_display_roundtrip(state.display);
230 assert(state.compositor && state.layer_shell && state.output && state.shm);
231
232 // Second roundtrip to get output properties
233 wl_display_roundtrip(state.display);
234
(gdb) p state.compositor
$1 = (struct wl_compositor *) 0x0
(gdb) p state.layer_shell
$2 = (struct zwlr_layer_shell_v1 *) 0x0
(gdb) p state.output
$3 = (struct wl_output *) 0x0
(gdb) p state.shm
$4 = (struct wl_shm *) 0x0
d) sway segfaults 1/10 times
Core was generated by `sway'.
Program terminated with signal SIGABRT, Aborted.
#0 0x000014a1059f2eab in raise () from /lib64/libc.so.6
(gdb) bt
#0 0x000014a1059f2eab in raise () at /lib64/libc.so.6
#1 0x000014a1059dd5b9 in abort () at /lib64/libc.so.6
#2 0x000014a1059dd491 in _nl_load_domain.cold.0 () at /lib64/libc.so.6
#3 0x000014a1059eb612 in () at /lib64/libc.so.6
#4 0x000014a10641ca6d in get_drm_backend_from_backend (wlr_backend=0x258ed60) at ../backend/drm/backend.c:20
#5 0x000014a10642135d in page_flip_handler (fd=9, seq=743371, tv_sec=789424, tv_usec=91398, user=0x20a7ee0) at ../backend/drm/drm.c:1135
#6 0x000014a101fdb8ed in drmHandleEvent () at /lib64/libdrm.so.2
#7 0x000014a10642146f in handle_drm_event (fd=9, mask=1, data=0x0) at ../backend/drm/drm.c:1164
#8 0x000014a10669e9b2 in wl_event_loop_dispatch (loop=0x1a35f40, timeout=timeout@entry=-1) at src/event-loop.c:641
#9 0x000014a10669d70a in wl_display_run (display=0x1a38500) at src/wayland-server.c:1260
#10 0x00000000004157d5 in server_run (server=0x666ae0 <server>) at ../sway/server.c:165
#11 0x0000000000414fa3 in main (argc=1, argv=0x7ffeb7813798) at ../sway/main.c:384
(gdb) f 4
#4 0x000014a10641ca6d in get_drm_backend_from_backend (wlr_backend=0x258ed60) at ../backend/drm/backend.c:20
20 assert(wlr_backend_is_drm(wlr_backend));
(gdb) l
15 #include "backend/drm/drm.h"
16 #include "util/signal.h"
17
18 struct wlr_drm_backend *get_drm_backend_from_backend(
19 struct wlr_backend *wlr_backend) {
20 assert(wlr_backend_is_drm(wlr_backend));
21 return (struct wlr_drm_backend *)wlr_backend;
22 }
23
24 static bool backend_start(struct wlr_backend *backend) {
(gdb) p wlr_backend
$1 = (struct wlr_backend *) 0x258ed60
(gdb) p *wlr_backend
$2 = {impl = 0x90, events = {destroy = {listener_list = {prev = 0x211, next = 0x20a7ed0}}, new_input = {listener_list = {prev = 0x23b8b80, next = 0x1100000006}}, new_output = {listener_list = {
prev = 0x2422a00, next = 0x2380410}}}}
It looks like the sway-specific part of this is fixed and the remaining issue is in wlroots. Can you test this out with rootston, and if it also fails, create an issue in wlroots?
https://github.com/swaywm/wlroots/pull/1301 probably fixes the get_drm_backend_from_backend issue. @ivyl Can you please update wlroots and test again?
@RyanDwyer @emersion yep, seems like I don't see any backtraces that would suggests it's sway at fault. No get-drm_backend_from_backend issue too after 20-ish runs.
I'll do a couple of test rounds with my home setup later and file the findings, if any, in the correct project.
Thanks! :-)
I'm running into this same issue with everything from git. This is with just my normal eDP laptop and an HDMI screen connected. Oddly enough the HDMI output shows up as DP1 in Xorg.
sway-git r5104.51ad2676-1
wlroots-git 0.1.r9.gc55d1542-1
Log
log.txt
Can you provide a backtrace? (coredumpctl gdb sway and then bt full)
@emersion Here you go gdb.txt
I have the same issue as parkerlreed on sway version 1.0-beta.1-108-gb90af335 (Oct 30 2018, branch 'master').
Sway starts normally when the extra screen is not plugged into my laptop's dock, and when plugging the extra screen in later it also works (background and swaybar both showing on the extra screen).
However when trying to start sway (with default config) with both screens plugged in I get swaybg: ../sway/swaybg/main.c:235: main: Assertion state.compositor && state.layer_shell && state.output && state.shm' failed. This occurs consistently.
A small aside: my dock reports the DVI connection I have as HDMI for some reason.
Most helpful comment
I have the same issue as parkerlreed on
sway version 1.0-beta.1-108-gb90af335 (Oct 30 2018, branch 'master').Sway starts normally when the extra screen is not plugged into my laptop's dock, and when plugging the extra screen in later it also works (background and swaybar both showing on the extra screen).
However when trying to start sway (with default config) with both screens plugged in I get
swaybg: ../sway/swaybg/main.c:235: main: Assertion state.compositor && state.layer_shell && state.output && state.shm' failed. This occurs consistently.A small aside: my dock reports the DVI connection I have as HDMI for some reason.
My debug log