sway: Sway crashes when the window is closed while IME is active

Please read the following before submitting:

  • Please do NOT submit bug reports for questions. Ask questions on IRC at #sway on Libera Chat.
  • Proprietary graphics drivers, including nvidia, are not supported. Please use the open source equivalents, such as nouveau, if you would like to use Sway.
  • Please do NOT submit issues for information from the github wiki. The github wiki is community maintained and therefore may contain outdated information, scripts that don’t work or obsolete workarounds. If you fix a script or find outdated information, don’t hesitate to adjust the wiki page.

Please fill out the following:

  • Sway Version:

    • sway version 1.10
  • Debug Log:

sway.log

  • Configuration File:
  • Minimal config that I use to reproduce the issue:
bindsym Mod1+F4 kill
bindsym --locked Mod4+Shift+j exec --no-startup-id systemd-cat -t anthywl "$HOME/.local/bin/anthywl.sh"
bindsym Mod4+x exec gedit
exec gedit
  • Stack Trace:
    • Stack trace is slightly different every time, but here is one that I got when I reproduced the issue with minimal config. I’ll add some more in the comments, but no debug log for them.
#0  0x00007fa3f8539851 in wlr_scene_node_coords (node=0x91, lx_ptr=lx_ptr@entry=0x7ffd3ed431d0, ly_ptr=ly_ptr@entry=0x7ffd3ed431d4) at ../wlroots-0.18.2/types/scene/wlr_scene.c:1101
#1  0x000055a6ba24f233 in arrange_popups (popups=0x55a6d8b4f0d0) at ../sway-1.10/sway/desktop/transaction.c:617
#2  0x000055a6ba24f64c in arrange_root (root=0x55a6d8b4e8b0) at ../sway-1.10/sway/desktop/transaction.c:687
#3  transaction_progress () at ../sway-1.10/sway/desktop/transaction.c:741
#4  0x000055a6ba24fed7 in transaction_commit_pending () at ../sway-1.10/sway/desktop/transaction.c:861
#5  0x000055a6ba25030a in _transaction_commit_dirty (server_request=server_request@entry=true) at ../sway-1.10/sway/desktop/transaction.c:937
#6  0x000055a6ba25043c in transaction_commit_dirty () at ../sway-1.10/sway/desktop/transaction.c:941
#7  0x000055a6ba27f6b5 in view_unmap (view=view@entry=0x55a6d9f15080) at ../sway-1.10/sway/tree/view.c:923
#8  0x000055a6ba2508bb in handle_unmap (listener=0x55a6d9f15290, data=<optimized out>) at ../sway-1.10/sway/desktop/xdg_shell.c:449
#9  0x00007fa3f85ea38e in wl_signal_emit_mutable (signal=signal@entry=0x55a6d9f37858, data=data@entry=0x0) at ../wayland-1.23.1/src/wayland-server.c:2314
#10 0x00007fa3f8548442 in wlr_surface_unmap (surface=0x55a6d9f37560) at ../wlroots-0.18.2/types/wlr_compositor.c:839
#11 0x00007fa3f85466b6 in destroy_xdg_toplevel (toplevel=0x55a6d9f35780) at ../wlroots-0.18.2/types/xdg_shell/wlr_xdg_toplevel.c:533
#12 0x00007fa3f8544b55 in destroy_xdg_surface_role_object (surface=surface@entry=0x55a6d9e6fc90) at ../wlroots-0.18.2/types/xdg_shell/wlr_xdg_surface.c:457
#13 0x00007fa3f8544b7c in xdg_surface_handle_role_resource_destroy (listener=0x55a6d9e6fdb8, data=<optimized out>) at ../wlroots-0.18.2/types/xdg_shell/wlr_xdg_surface.c:474
#14 0x00007fa3f85eab9f in wl_priv_signal_final_emit (signal=signal@entry=0x55a6d9f6ef80, data=data@entry=0x55a6d9f6ef20) at ../wayland-1.23.1/src/wayland-server.c:2478
#15 0x00007fa3f85eac70 in remove_and_destroy_resource (element=element@entry=0x55a6d9f6ef20, data=data@entry=0x0, flags=0) at ../wayland-1.23.1/src/wayland-server.c:754
#16 0x00007fa3f85eacb1 in wl_resource_destroy (resource=0x55a6d9f6ef20) at ../wayland-1.23.1/src/wayland-server.c:782
#17 0x00007fa3f8545a3a in xdg_toplevel_handle_destroy (client=<optimized out>, resource=<optimized out>) at ../wlroots-0.18.2/types/xdg_shell/wlr_xdg_toplevel.c:426
#18 0x00007fa3f7c91336 in ffi_call_unix64 () at /tmp/portage/dev-libs/libffi-3.4.6-r2/work/libffi-3.4.6/src/x86/unix64.S:104
#19 0x00007fa3f7c90940 in ffi_call_int (cif=cif@entry=0x7ffd3ed43630, fn=fn@entry=0x7fa3f8545a2a <xdg_toplevel_handle_destroy>, rvalue=<optimized out>, rvalue@entry=0x0, avalue=avalue@entry=0x7ffd3ed43700, closure=closure@entry=0x0)
    at /tmp/portage/dev-libs/libffi-3.4.6-r2/work/libffi-3.4.6/src/x86/ffi64.c:676
#20 0x00007fa3f7c90ea4 in ffi_call (cif=cif@entry=0x7ffd3ed43630, fn=<optimized out>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0x7ffd3ed43700) at /tmp/portage/dev-libs/libffi-3.4.6-r2/work/libffi-3.4.6/src/x86/ffi64.c:713
#21 0x00007fa3f85ee6c9 in wl_closure_invoke (closure=0x55a6d9e66da0, flags=<optimized out>, target=<optimized out>, opcode=0, data=<optimized out>) at ../wayland-1.23.1/src/connection.c:1228
#22 0x00007fa3f85eb00c in wl_client_connection_data (fd=<optimized out>, mask=<optimized out>, data=0x55a6d9f00920) at ../wayland-1.23.1/src/wayland-server.c:444
#23 0x00007fa3f85ebefd in wl_event_source_fd_dispatch (source=<optimized out>, ep=<optimized out>) at ../wayland-1.23.1/src/event-loop.c:113
#24 0x00007fa3f85ecd7f in wl_event_loop_dispatch (loop=0x55a6d8b4e7b0, timeout=<optimized out>, timeout@entry=-1) at ../wayland-1.23.1/src/event-loop.c:1105
#25 0x00007fa3f85eb1e4 in wl_display_run (display=0x55a6d8b4e6c0) at ../wayland-1.23.1/src/wayland-server.c:1530
#26 0x000055a6ba24b185 in server_run (server=server@entry=0x55a6ba2ad4e0 <server>) at ../sway-1.10/sway/server.c:501
#27 0x000055a6ba249fc3 in main (argc=<optimized out>, argv=0x7ffd3ed43c58) at ../sway-1.10/sway/main.c:373
  • Description: Steps to reproduce:
  1. Open any window wit an input area. I used Gedit to reproduce, but I had crashes with Firefox too.
  2. Start an IME. I use anthywl.
  3. Input something.
  4. Close the window with a keyboard shortcut. Gedit shows the dialogue “save or not”, I click “no save” and then get sway crash.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 17 (6 by maintainers)

Most upvoted comments

I think it is because the wlr_scene_tree is destoried but the wlr_scene_node is still alive, then wl_container_of tried to find the scene_tree, finally it found a invaild ptr, that caused coredump

Maybe the problem is in the logic of the logic to call the hot key… I think. Maybe that place the scene is not properly handled

Image

And the logic went into the 56 line in wlr_scene.c, which caused the code got a invalid ptr

Image

And this one with Firefox:

#0  0x00007f251cb0d5a3 in scene_node_get_root (node=node@entry=0x561f7068b4b0) at ../wlroots-0.18.2/types/scene/wlr_scene.c:51
#1  0x00007f251cb0eac9 in wlr_scene_node_destroy (node=0x561f7068b4b0) at ../wlroots-0.18.2/types/scene/wlr_scene.c:102
#2  0x0000561f5b59d011 in input_popup_set_focus (popup=popup@entry=0x561f70609880, surface=0x561f704ec9d0) at ../sway-1.10/sway/input/text_input.c:376
#3  0x0000561f5b59d1ef in relay_send_im_state (relay=0x561f6fef4680, input=<optimized out>) at ../sway-1.10/sway/input/text_input.c:238
#4  0x0000561f5b59d458 in handle_text_input_enable (listener=0x561f704af9f0, data=<optimized out>) at ../sway-1.10/sway/input/text_input.c:255
#5  0x00007f251cbbe38e in wl_signal_emit_mutable (signal=signal@entry=0x561f704af968, data=data@entry=0x561f704af8a0) at ../wayland-1.23.1/src/wayland-server.c:2314
#6  0x00007f251cb36ca0 in text_input_commit (client=<optimized out>, resource=<optimized out>) at ../wlroots-0.18.2/types/wlr_text_input_v3.c:189
#7  0x00007f251c265336 in ffi_call_unix64 () at /tmp/portage/dev-libs/libffi-3.4.6-r2/work/libffi-3.4.6/src/x86/unix64.S:104
#8  0x00007f251c264940 in ffi_call_int (cif=cif@entry=0x7ffcada76730, fn=fn@entry=0x7f251cb36bd3 <text_input_commit>, rvalue=<optimized out>, rvalue@entry=0x0, avalue=avalue@entry=0x7ffcada76800, closure=closure@entry=0x0)
    at /tmp/portage/dev-libs/libffi-3.4.6-r2/work/libffi-3.4.6/src/x86/ffi64.c:676
#9  0x00007f251c264ea4 in ffi_call (cif=cif@entry=0x7ffcada76730, fn=<optimized out>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0x7ffcada76800) at /tmp/portage/dev-libs/libffi-3.4.6-r2/work/libffi-3.4.6/src/x86/ffi64.c:713
#10 0x00007f251cbc26c9 in wl_closure_invoke (closure=0x561f705cc960, flags=<optimized out>, target=<optimized out>, opcode=7, data=<optimized out>) at ../wayland-1.23.1/src/connection.c:1228
#11 0x00007f251cbbf00c in wl_client_connection_data (fd=<optimized out>, mask=<optimized out>, data=0x561f70007f80) at ../wayland-1.23.1/src/wayland-server.c:444
#12 0x00007f251cbbfefd in wl_event_source_fd_dispatch (source=<optimized out>, ep=<optimized out>) at ../wayland-1.23.1/src/event-loop.c:113
#13 0x00007f251cbc0d7f in wl_event_loop_dispatch (loop=0x561f6f0f5790, timeout=<optimized out>, timeout@entry=-1) at ../wayland-1.23.1/src/event-loop.c:1105
#14 0x00007f251cbbf1e4 in wl_display_run (display=0x561f6f0f56a0) at ../wayland-1.23.1/src/wayland-server.c:1530
#15 0x0000561f5b589185 in server_run (server=server@entry=0x561f5b5eb4e0 <server>) at ../sway-1.10/sway/server.c:501
#16 0x0000561f5b587fc3 in main (argc=<optimized out>, argv=0x7ffcada76d58) at ../sway-1.10/sway/main.c:373