{"action":"created","issue":{"url":"https://api.github.com/repos/swaywm/sway/issues/2754","repository_url":"https://api.github.com/repos/swaywm/sway","labels_url":"https://api.github.com/repos/swaywm/sway/issues/2754/labels{/name}","comments_url":"https://api.github.com/repos/swaywm/sway/issues/2754/comments","events_url":"https://api.github.com/repos/swaywm/sway/issues/2754/events","html_url":"https://github.com/swaywm/sway/issues/2754","id":366213386,"node_id":"MDU6SXNzdWUzNjYyMTMzODY=","number":2754,"title":"Sway crashes when two dispalys are connected at the same time","user":{"login":"ivyl","id":16490,"node_id":"MDQ6VXNlcjE2NDkw","avatar_url":"https://avatars1.githubusercontent.com/u/16490?v=4","gravatar_id":"","url":"https://api.github.com/users/ivyl","html_url":"https://github.com/ivyl","followers_url":"https://api.github.com/users/ivyl/followers","following_url":"https://api.github.com/users/ivyl/following{/other_user}","gists_url":"https://api.github.com/users/ivyl/gists{/gist_id}","starred_url":"https://api.github.com/users/ivyl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivyl/subscriptions","organizations_url":"https://api.github.com/users/ivyl/orgs","repos_url":"https://api.github.com/users/ivyl/repos","events_url":"https://api.github.com/users/ivyl/events{/privacy}","received_events_url":"https://api.github.com/users/ivyl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-10-03T07:46:59Z","updated_at":"2018-10-03T12:06:29Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"## The Setup\r\nI have one DP1.2 monitor that includes a HUB, which allows me to \"daisy-chain\" a second screen. \r\n\r\n`SNIP /sys/kernel/debug/dri/0/i915_display_info`\r\n```\r\nconnector 79: type DP-2, status: disconnected\r\n        DPCD rev: 12\r\n        audio support: no\r\n        DP branch device present: yes\r\n                Type: DisplayPort\r\n                ID: Dp1.2\r\n                HW: 0.0\r\n                SW: 0.21\r\n        modes:\r\n```\r\n\r\nThis gives me two additional connectors, DP-5 and DP-6. \r\n`SNIP /sys/kernel/debug/dri/0/i915_display_info`\r\n```\r\nconnector 120: type DP-5, status: connected\r\n        name:\r\n        physical dimensions: 640x400mm\r\n        subpixel order: Unknown\r\n        CEA rev: 3\r\n        audio support: yes\r\n\r\nconnector 151: type DP-6, status: connected\r\n        name:\r\n        physical dimensions: 520x320mm\r\n        subpixel order: Unknown\r\n        CEA rev: 3\r\n        audio support: yes\r\n```\r\n\r\n## The Issue\r\nWhenever 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):\r\n\r\n`gdb coredump`\r\n```\r\nCore was generated by `sway'.\r\nProgram terminated with signal SIGSEGV, Segmentation fault.\r\n#0  0x0000000000423521 in seat_get_focused_workspace (seat=0xe5e9b0) at ../sway/input/seat.c:965\r\n965             if (focus->type == N_CONTAINER) {\r\n(gdb) bt\r\n#0  0x0000000000423521 in seat_get_focused_workspace (seat=0xe5e9b0) at ../sway/input/seat.c:965\r\n#1  0x0000000000447226 in workspace_by_name (name=0x12585a0 \"1:q\") at ../sway/tree/workspace.c:291\r\n#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\r\n#3  0x0000000000446f40 in workspace_next_name (output_name=0x105ef00 \"DP-5\") at ../sway/tree/workspace.c:238\r\n#4  0x00000000004489d5 in output_enable (output=0x12b7930, oc=0xe4cde0) at ../sway/tree/output.c:81\r\n#5  0x0000000000418890 in handle_new_output (listener=0x666b18 <server+56>, data=0x105eed0) at ../sway/desktop/output.c:552\r\n#6  0x0000146e8e935441 in wlr_signal_emit_safe (signal=0x804fc8, data=0x105eed0) at ../util/signal.c:29\r\n#7  0x0000146e8e8f9316 in new_output_reemit (listener=0x9883f8, data=0x105eed0) at ../backend/multi/backend.c:120\r\n#8  0x0000146e8e935441 in wlr_signal_emit_safe (signal=0x80efb8, data=0x105eed0) at ../util/signal.c:29\r\n#9  0x0000146e8e8f22f2 in scan_drm_connectors (drm=0x80ef90) at ../backend/drm/drm.c:1124\r\n#10 0x0000146e8e8ede94 in drm_invalidated (listener=0x80f070, data=0x805030) at ../backend/drm/backend.c:118\r\n#11 0x0000146e8e935441 in wlr_signal_emit_safe (signal=0x7fdc10, data=0x805030) at ../util/signal.c:29\r\n#12 0x0000146e8e8fa116 in udev_event (fd=6, mask=1, data=0x805030) at ../backend/session/session.c:51\r\n#13 0x0000146e8eb6f9b2 in wl_event_loop_dispatch (loop=0x7fcf40, timeout=timeout@entry=-1) at src/event-loop.c:641\r\n#14 0x0000146e8eb6e70a in wl_display_run (display=0x7ff500) at src/wayland-server.c:1260\r\n#15 0x0000000000415785 in server_run (server=0x666ae0 <server>) at ../sway/server.c:165\r\n#16 0x0000000000414f53 in main (argc=1, argv=0x7ffc94ea2638) at ../sway/main.c:384\r\n(gdb) l\r\n960     struct sway_workspace *seat_get_focused_workspace(struct sway_seat *seat) {\r\n961             struct sway_node *focus = seat_get_focus(seat);\r\n962             if (!focus) {\r\n963                     return NULL;\r\n964             }\r\n965             if (focus->type == N_CONTAINER) {\r\n966                     return focus->sway_container->workspace;\r\n967             }\r\n968             if (focus->type == N_WORKSPACE) {\r\n969                     return focus->sway_workspace;\r\n(gdb) p focus\r\n$1 = (struct sway_node *) 0x1\r\n```\r\n\r\nIf 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."},"comment":{"url":"https://api.github.com/repos/swaywm/sway/issues/comments/426612393","html_url":"https://github.com/swaywm/sway/issues/2754#issuecomment-426612393","issue_url":"https://api.github.com/repos/swaywm/sway/issues/2754","id":426612393,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNjYxMjM5Mw==","user":{"login":"ivyl","id":16490,"node_id":"MDQ6VXNlcjE2NDkw","avatar_url":"https://avatars1.githubusercontent.com/u/16490?v=4","gravatar_id":"","url":"https://api.github.com/users/ivyl","html_url":"https://github.com/ivyl","followers_url":"https://api.github.com/users/ivyl/followers","following_url":"https://api.github.com/users/ivyl/following{/other_user}","gists_url":"https://api.github.com/users/ivyl/gists{/gist_id}","starred_url":"https://api.github.com/users/ivyl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ivyl/subscriptions","organizations_url":"https://api.github.com/users/ivyl/orgs","repos_url":"https://api.github.com/users/ivyl/repos","events_url":"https://api.github.com/users/ivyl/events{/privacy}","received_events_url":"https://api.github.com/users/ivyl/received_events","type":"User","site_admin":false},"created_at":"2018-10-03T12:06:29Z","updated_at":"2018-10-03T12:06:29Z","author_association":"CONTRIBUTOR","body":"> @ivyl Can you please try with the following?\r\n\r\nIndeed, 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.\r\n\r\nAfter about 20 power cycles of the main monitor:\r\na) all graphic applications just die, including swaylock\r\nb) sometimes one of the outputs does not get up and remains blank\r\nc) swaybg segfaults all the time\r\n```\r\nCore was generated by `swaybg 0 /home/ahiler/pictures/n0x244u8ajez.png fill'.\r\nProgram terminated with signal SIGABRT, Aborted.\r\n#0  0x000014da033c6eab in raise () from /lib64/libc.so.6\r\n(gdb) bt\r\n#0  0x000014da033c6eab in raise () at /lib64/libc.so.6\r\n#1  0x000014da033b15b9 in abort () at /lib64/libc.so.6\r\n#2  0x000014da033b1491 in _nl_load_domain.cold.0 () at /lib64/libc.so.6\r\n#3  0x000014da033bf612 in  () at /lib64/libc.so.6\r\n#4  0x0000000000402d99 in main (argc=4, argv=0x7ffe092456a8) at ../swaybg/main.c:230\r\n(gdb) f 4\r\n#4  0x0000000000402d99 in main (argc=4, argv=0x7ffe092456a8) at ../swaybg/main.c:230\r\n230             assert(state.compositor && state.layer_shell && state.output && state.shm);\r\n(gdb) l\r\n225             assert(state.display);\r\n226\r\n227             struct wl_registry *registry = wl_display_get_registry(state.display);\r\n228             wl_registry_add_listener(registry, &registry_listener, &state);\r\n229             wl_display_roundtrip(state.display);\r\n230             assert(state.compositor && state.layer_shell && state.output && state.shm);\r\n231\r\n232             // Second roundtrip to get output properties\r\n233             wl_display_roundtrip(state.display);\r\n234\r\n(gdb) p state.compositor\r\n$1 = (struct wl_compositor *) 0x0\r\n(gdb) p state.layer_shell\r\n$2 = (struct zwlr_layer_shell_v1 *) 0x0\r\n(gdb) p state.output\r\n$3 = (struct wl_output *) 0x0\r\n(gdb) p state.shm\r\n$4 = (struct wl_shm *) 0x0\r\n\r\n```\r\nd) sway segfaults 1/10 times\r\n```\r\nCore was generated by `sway'.\r\nProgram terminated with signal SIGABRT, Aborted.\r\n#0  0x000014a1059f2eab in raise () from /lib64/libc.so.6\r\n(gdb) bt\r\n#0  0x000014a1059f2eab in raise () at /lib64/libc.so.6\r\n#1  0x000014a1059dd5b9 in abort () at /lib64/libc.so.6\r\n#2  0x000014a1059dd491 in _nl_load_domain.cold.0 () at /lib64/libc.so.6\r\n#3  0x000014a1059eb612 in  () at /lib64/libc.so.6\r\n#4  0x000014a10641ca6d in get_drm_backend_from_backend (wlr_backend=0x258ed60) at ../backend/drm/backend.c:20\r\n#5  0x000014a10642135d in page_flip_handler (fd=9, seq=743371, tv_sec=789424, tv_usec=91398, user=0x20a7ee0) at ../backend/drm/drm.c:1135\r\n#6  0x000014a101fdb8ed in drmHandleEvent () at /lib64/libdrm.so.2\r\n#7  0x000014a10642146f in handle_drm_event (fd=9, mask=1, data=0x0) at ../backend/drm/drm.c:1164\r\n#8  0x000014a10669e9b2 in wl_event_loop_dispatch (loop=0x1a35f40, timeout=timeout@entry=-1) at src/event-loop.c:641\r\n#9  0x000014a10669d70a in wl_display_run (display=0x1a38500) at src/wayland-server.c:1260\r\n#10 0x00000000004157d5 in server_run (server=0x666ae0 <server>) at ../sway/server.c:165\r\n#11 0x0000000000414fa3 in main (argc=1, argv=0x7ffeb7813798) at ../sway/main.c:384\r\n(gdb) f 4\r\n#4  0x000014a10641ca6d in get_drm_backend_from_backend (wlr_backend=0x258ed60) at ../backend/drm/backend.c:20\r\n20              assert(wlr_backend_is_drm(wlr_backend));\r\n(gdb) l\r\n15      #include \"backend/drm/drm.h\"\r\n16      #include \"util/signal.h\"\r\n17\r\n18      struct wlr_drm_backend *get_drm_backend_from_backend(\r\n19                      struct wlr_backend *wlr_backend) {\r\n20              assert(wlr_backend_is_drm(wlr_backend));\r\n21              return (struct wlr_drm_backend *)wlr_backend;\r\n22      }\r\n23\r\n24      static bool backend_start(struct wlr_backend *backend) {\r\n(gdb) p wlr_backend\r\n$1 = (struct wlr_backend *) 0x258ed60\r\n(gdb) p *wlr_backend\r\n$2 = {impl = 0x90, events = {destroy = {listener_list = {prev = 0x211, next = 0x20a7ed0}}, new_input = {listener_list = {prev = 0x23b8b80, next = 0x1100000006}}, new_output = {listener_list = {\r\n        prev = 0x2422a00, next = 0x2380410}}}}\r\n```"}}
{"actor":{"display_login":"ivyl"}}