swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.77k stars 1.11k forks source link

crash: failed assertion in swaybar #4497

Open sanga opened 5 years ago

sanga commented 5 years ago

I'm using i3status-rs and I recently configured that to open pavucontrol when clicking the sound block. Today I think was the first time I've actually used that and swaybar immediately crashed (well pavucontrol opened and then swaybar crashed). Might be a timing related thing or something. At least I haven't managed to repro the crash just now whilst running swaybar and opening pavucontrol a few more times.

version info

sway version 1.2-rc1-19-gff7d979d (Aug 20 2019, branch 'master')
wlroots=e19f48d1e4cea6bbb8998466553fffda4bd13251

stack


        set = {__val = {0, 139782811570551, 4222451712, 93900948120384, 93900948120485, 93900948120384, 93900948120384, 93900948120518, 93900948120684, 93900948120384, 93900948120684, 0, 0, 0, 0, 0}}
        pid = <optimized out>
        tid = <optimized out>
#1  0x00007f21b8cdf535 in __GI_abort () at abort.c:79
        save_stage = 1
        act =
          {__sigaction_handler = {sa_handler = 0x556704a76a70, sa_sigaction = 0x556704a76a70}, sa_mask = {__val = {0, 93900948120384, 0, 0, 0, 0, 21474836480, 140729636459416, 140729636459264, 139782812799216, 139782812784008, 0, 17923299014683965952, 139782812768743, 0, 139782812784008}}, sa_flags = 45805584, sa_restorer = 0x556702baf1f0}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007f21b8cdf40f in __assert_fail_base
    (fmt=0x7f21b8e6d588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x556702baf1f0 "bar->compositor && bar->layer_shell && bar->shm && bar->xdg_output_manager", file=0x556702baf010 "swaybar/bar.c", line=418, function=<optimized out>) at assert.c:92
        str = 0x556704a76a70 "@f\247\004gU"
        total = 4096
#3  0x00007f21b8cef012 in __GI___assert_fail
    (assertion=0x556702baf1f0 "bar->compositor && bar->layer_shell && bar->shm && bar->xdg_output_manager", file=0x556702baf010 "swaybar/bar.c", line=418, function=0x556702baf2c8 <__PRETTY_FUNCTION__.22991> "bar_setup") at assert.c:101
#4  0x0000556702b9c441 in bar_setup (bar=0x556702bb8420 <swaybar>, socket_path=0x556704a80ac0 "/run/user/1000/sway-ipc.1000.789.sock") at ../swaybar/bar.c:417
        registry = 0x556704a7ecc0
        __PRETTY_FUNCTION__ = "bar_setup"
        seat = 0x7f21b8dbb72e <getopt_long+14>
#5  0x0000556702ba18e4 in main (argc=3, argv=0x7ffe2bfd95c8) at ../swaybar/main.c:90
        socket_path = 0x556704a80ac0 "/run/user/1000/sway-ipc.1000.789.sock"
        debug = false
        long_options =
            {{name = 0x556702baffc7 "help", has_arg = 0, flag = 0x0, val = 104}, {name = 0x556702baffcc "version", has_arg = 0, flag = 0x0, val = 118}, {name = 0x556702baffd4 "socket", has_arg = 1, flag = 0x0, val = 115}, {name = 0x556702baffdb "bar_id", has_arg = 1, flag = 0x0, val = 98}, {name = 0x556702baffe2 "debug", has_arg = 0, flag = 0x0, val = 100}, {name = 0x0, has_arg = 0, flag = 0x0, val = 0}}
        usage = 0x556702bafd10 "Usage: swaybar [options...]\n\n  -h, --help", ' ' <repeats 13 times>, "Show help message and quit.\n  -v, --version          Show the version number and quit.\n  -s, --socket <socket>  Connect to sway via socket.\n  -b, "...
        c = -1```
sanga commented 5 years ago

Actually this repros 100% of the time when running swaybar as part of the regular sway session. Doesn't repro running swaybar from a shell in Sway though.

johnae commented 5 years ago

I have the same issue. Not running i3status-rs. Have had this for some time, not sure when I first noticed it unfortunately.

vvrein commented 5 years ago

Same thing, but i think that was issue of i3status-rs, now seems - no https://github.com/greshake/i3status-rust/issues/420

sanga commented 5 years ago

So I’d guess that when whatever statusline program behaves unexpectedly ie crashes then that causes swaybar to crash. So i3statusrs needs to be fixed but swaybar should also arguably be hardened to account for crashy statusline progs

madic-creates commented 5 years ago

This not only happens with pavucontrol but also nm-connection-editor

ianyfan commented 4 years ago

Is this still a problem? Could someone provide minimal reproduction steps please?

sanga commented 4 years ago

repros here on:

sway version 1.4-9c93e1c0 (Jan 24 2020, branch 'master')
wlroots=3ff6a5def349db21c9f7d83c0406ce5cebfa9a09

Repro steps are:

  1. install i3statusrs
  2. use the following conf (excerpt) for sway
    bar {
    status_command $HOME/.local/bin/i3status-rs $HOME/.config/i3/i3statusrs.toml
    }

    and the following conf (excerpt) for i3statusrs

    [[block]]
    block = "sound"
    on_click = "pavucontrol"
  3. click on the speaker icon on the status bar to launch pavucontrol => observe swaybar die

Sorry, that's a bit involved but I don't have nicer steps than that at the moment

ammgws commented 4 years ago

Are you running i3status-rust master? I think there was an issue a little while back that fixed this (issue was i3status-rust printing the commands output to stdin)

Ah I missed the comment above about hardening swaybar regardless

sanga commented 4 years ago

Doesn't appear to be fixed in either sway or i3status-rs. I still get the swaybar crash when running i3status-rs from master updated just a moment ago. And yeah, as mentioned earlier, even if i3status-rs is fixed the bug would still presumably be in swaybar that it crashes on unexpected input.

Thinking about it now I wonder if one could crash swaybar just by making a simple program that dumps a stacklike block of text to swaybar. I wonder if it's that simple...

ammgws commented 4 years ago

i3 version 4.18 (2020-02-17) sway version 1.4-b34c198f (Mar 22 2020) i3status-rs 0.13.0 (git)

Here are my findings: i3rs on-click cmd sway i3
pavucontrol crashes swaybar no issue
swaymsg exec pavucontrol no issue -
sanga commented 4 years ago

thank you @ammgws ! To confirm switching from raw pavucontrol to swaymsg exec pavucontrol in i3statusrs' "fixes" the crash for me too (double-quotes as presumably the bug is still there it's just not triggered that way).