ErikReider / SwayAudioIdleInhibit

GNU General Public License v3.0
158 stars 14 forks source link

Frequent core dumps #7

Open lilacpixel opened 1 year ago

lilacpixel commented 1 year ago

sway-audio-idle-inhibit crashes extremely frequently on my machine, which I usually only notice when sway idles during a video or Zoom call. coredumpctl list shows that it crashes at least once a day, more often if I manually relaunch after each crash. Since it happens silently at some point during a sway session, it's hard to know what the trigger might be.

Output of coredump info from the latest crash:

           PID: 88781 (sway-audio-idle)
           UID: 1000 (cari)
           GID: 1000 (cari)
        Signal: 6 (ABRT)
     Timestamp: Wed 2023-05-17 11:30:36 EDT (6h ago)
  Command Line: sway-audio-idle-inhibit
    Executable: /usr/local/bin/sway-audio-idle-inhibit
 Control Group: /user.slice/user-1000.slice/session-29.scope
          Unit: session-29.scope
         Slice: user-1000.slice
       Session: 29
     Owner UID: 1000 (cari)
       Boot ID: 9e95db0c558149368427a1fdd4b39fed
    Machine ID: 2c2c6afe3cae4196ad2e3df724d38f87
      Hostname: artemis
       Storage: /var/lib/systemd/coredump/core.sway-audio-idle.1000.9e95db0c558149368427a1fdd4b39fed.88781.1684337436000000.zst (present)
  Size on Disk: 170.9K
       Message: Process 88781 (sway-audio-idle) of user 1000 dumped core.

                Module liblz4.so.1 from rpm lz4-1.9.4-2.fc38.x86_64
                Module libzstd.so.1 from rpm zstd-1.5.5-1.fc38.x86_64
                Module liblzma.so.5 from rpm xz-5.4.1-1.fc38.x86_64
                Module libcap.so.2 from rpm libcap-2.48-6.fc38.x86_64
                Module libXau.so.6 from rpm libXau-1.0.11-2.fc38.x86_64
                Module libmpg123.so.0 from rpm mpg123-1.31.3-1.fc38.x86_64
                Module libogg.so.0 from rpm libogg-1.3.5-5.fc38.x86_64
                Module libopus.so.0 from rpm opus-1.3.1-12.fc38.x86_64
                Module libvorbisenc.so.2 from rpm libvorbis-1.3.7-7.fc38.x86_64
                Module libvorbis.so.0 from rpm libvorbis-1.3.7-7.fc38.x86_64
                Module libFLAC.so.12 from rpm flac-1.4.2-2.fc38.x86_64
                Module libgsm.so.1 from rpm gsm-1.0.22-2.fc38.x86_64
                Module libsystemd.so.0 from rpm systemd-253.4-1.fc38.x86_64
                Module libxcb.so.1 from rpm libxcb-1.13.1-11.fc38.x86_64
                Module libsndfile.so.1 from rpm libsndfile-1.1.0-6.fc38.x86_64
                Module libffi.so.8 from rpm libffi-3.4.4-2.fc38.x86_64
                Module libdbus-1.so.3 from rpm dbus-1.14.6-1.fc38.x86_64
                Module libpulsecommon-16.1.so from rpm pulseaudio-16.1-4.fc38.x86_64
                Module libwayland-client.so.0 from rpm wayland-1.22.0-1.fc38.x86_64
                Module libpulse.so.0 from rpm pulseaudio-16.1-4.fc38.x86_64
                Stack trace of thread 88781:
                #0  0x00007f89b90b0844 __pthread_kill_implementation (libc.so.6 + 0x8e844)
                #1  0x00007f89b905fabe raise (libc.so.6 + 0x3dabe)
                #2  0x00007f89b904887f abort (libc.so.6 + 0x2687f)
                #3  0x00007f89b904960f __libc_message.cold (libc.so.6 + 0x2760f)
                #4  0x00007f89b9144979 __fortify_fail (libc.so.6 + 0x122979)
                #5  0x00007f89b9144954 __stack_chk_fail (libc.so.6 + 0x122954)
                #6  0x00007f89b962b898 wl_display_roundtrip_queue (libwayland-client.so.0 + 0xb898)

                Stack trace of thread 88784:
                #0  0x00007f89b912735d __poll (libc.so.6 + 0x10535d)
                #1  0x00007f89b9666526 poll_func (libpulse.so.0 + 0x35526)
                #2  0x00007f89b964f694 pa_mainloop_poll (libpulse.so.0 + 0x1e694)
                #3  0x00007f89b965a153 pa_mainloop_iterate (libpulse.so.0 + 0x29153)
                #4  0x00007f89b965a218 pa_mainloop_run (libpulse.so.0 + 0x29218)
                #5  0x00007f89b966a751 thread (libpulse.so.0 + 0x39751)
                #6  0x00007f89b95d7d7b internal_thread_func (libpulsecommon-16.1.so + 0x60d7b)
                #7  0x00007f89b90ae907 start_thread (libc.so.6 + 0x8c907)
                #8  0x00007f89b9134870 __clone3 (libc.so.6 + 0x112870)
                ELF object binary architecture: AMD x86-64

Using Fedora 38; the problem occurs on both swayfx 0.2 and vanilla sway 1.8.1.

Thanks for taking a look! ☺️

ErikReider commented 1 year ago

I'm also running Fedora 38 with swayfx and it seems like I'm also experiencing these crashes even since 2023-05-04.

It'll be difficult to be able to fix this without an easy way of reproducing.

If you find out what's causing this, please notify me :)

Druneau commented 1 year ago

Hi,

I'm getting the same crashes on Fedora 38 Sway Spin (vanilla).

The only information I can add is that I notice the crashed happens when going from "NOT IDLE INHIBITED" to playing sound again. When running through a terminal I get this output at crash-time:

NOT IDLE INHIBITED
NOT IDLE INHIBITED  (Start playing music through firefox)
*** stack smashing detected ***:  terminated
Aborted (core dumped)

I can't seem to reliably reproduce yet. I will keep trying.

EDIT:

I am using a laptop plugged through a USB-C Dock. Audio gets switched from a USB DAC to Laptop speakers on disconnection from dock.

I seem to be able to reproduce the crash if I

  1. Play some audio with the dock connected (thus external audio device)
  2. Disconnect the USB-C Connection (thus the external USB DAC)

This (most of the time) results in the " stack smashing detected " on my command line. I was able to get 3 within 5 minutes.

I am not familiar with debugging tools on linux, but I will try and see if I can reproduce with a debugger attached later today.

Druneau commented 1 year ago

So, this is without any external USB DAC plugged in my USB-C Dock. I can still make sway-audio-idle-inhibit crash by plugging/unplugging my USB-C Dock, AND THEN either pausing or playing the media. That seems to be what triggers the crash, when the media play state changes (going either way)

Output from gdb:

[dbruneau@gris build]$ gdb sway-audio-idle-inhibit
GNU gdb (GDB) Fedora Linux 13.1-4.fc38
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from sway-audio-idle-inhibit...
(gdb) run
Starting program: /home/dbruneau/tempDocuments/SwayAudioIdleInhibit/build/sway-audio-idle-inhibit 

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.fedoraproject.org/>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]                                                     
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff73e06c0 (LWP 344295)]                                                          
NOT IDLE INHIBITED
NOT IDLE INHIBITED
IDLE INHIBITED
NOT IDLE INHIBITED
IDLE INHIBITED
NOT IDLE INHIBITED
*** stack smashing detected ***: terminated

Thread 1 "sway-audio-idle" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, 
    no_tid=no_tid@entry=0) at pthread_kill.c:44
44       return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;           
(gdb) 

I've tried the laptop on its own with a charging brick only to see if the issue happened simply when the power state changes from AC to Battery (or vice versa) since the dock provides power.

I will do some tests with external display plugging/unplugging to see.

EDIT:

Simplest way for me to reproduce is to plug/unplug an external monitor on my laptop. I can make it crash everytime

  1. Plug or unplug an external monitor (swaywm then adds or removes the monitor)
  2. Play or pause any media
  3. sway-audio-idle-inhibit should have crashed

EDIT 2:

Faster way to re-create the crash:

  1. Start sway-audio-idle-inhibit
  2. disable and enable your display output using command similar to the following swaymsg output DP-2 disable; swaymsg output DP-2 enable
  3. Play or pause any audio and sway-audio-idle-inhibit should crash.
Druneau commented 1 year ago

Here's a crash with WAYLAND_DEBUG=1


[1287931.039]  -> zwp_idle_inhibit_manager_v1@5.create_inhibitor(new id zwp_idle_inhibitor_v1@6, wl_surface@3)
[1287931.055]  -> wl_display@1.sync(new id wl_callback@7)
[1287931.073] wl_registry@2.global_remove(103)
*** stack smashing detected ***: terminated
Aborted (core dumped) ```
ErikReider commented 1 year ago

Faster way to re-create the crash:

1. Start sway-audio-idle-inhibit

2. disable and enable your display output using command similar to the following `swaymsg output DP-2 disable; swaymsg output DP-2 enable`

3. Play or pause any audio and sway-audio-idle-inhibit should crash.

Awesome! Thanks for finding a way of reproducing it! I'll look into it :)

ErikReider commented 1 year ago

Does the PR fix it on your end? Works for me :)

Druneau commented 1 year ago

The PR fixes the crash on my end aswell! Awesome. Thanks a bunch.

ErikReider commented 1 year ago

Reopened due to the revert

brettalcox commented 10 months ago

Not amazing, but as a workaround, I've just thrown this into a systemd unit and have it auto restart on failure--works "perfect" :laughing:

ErikReider commented 6 months ago

I'm not experiencing this issue anymore, so I'll close this. Please reopen if this is still an issue :)

norpol commented 6 months ago

@ErikReider Please re-open, I'm still having reproducible crashes if I turn off my screen and turn it back on a while later. I'm on the version from https://github.com/ErikReider/SwayAudioIdleInhibit/pull/14

gokberkkocak commented 6 months ago

I think it might be a separate reason to crash, but after #18, every time I open pavucontrol, sway-audio-idle-inhibit crashes. Including the core dump below. Happy to move into another issue if its more suitable.

           PID: 823 (sway-audio-idle)
           UID: 1000 (gk)
           GID: 1000 (gk)
        Signal: 11 (SEGV)
     Timestamp: Mon 2024-02-12 21:38:51 GMT (24min ago)
  Command Line: sway-audio-idle-inhibit
    Executable: /usr/bin/sway-audio-idle-inhibit
 Control Group: /user.slice/user-1000.slice/session-2.scope
          Unit: session-2.scope
         Slice: user-1000.slice
       Session: 2
     Owner UID: 1000 (gk)
       Boot ID: d354919f200d45a196cf3f9e8e9afa4d
    Machine ID: 15eec52416ca461ba796153f59b5de7f
      Hostname: inspiron
       Storage: /var/lib/systemd/coredump/core.sway-audio-idle.1000.d354919f200d45a196cf3f9e8e9afa4d.823.1707773931000000.zst (present)
  Size on Disk: 203.5K
       Message: Process 823 (sway-audio-idle) of user 1000 dumped core.

                Stack trace of thread 828:
                #0  0x00007d0b9bd7782f n/a (libc.so.6 + 0x15982f)
                #1  0x0000585f5aa75859 n/a (sway-audio-idle-inhibit + 0x3859)
                #2  0x00007d0b9c2a72e0 n/a (libpulse.so.0 + 0x1f2e0)
                #3  0x00007d0b9c20c502 n/a (libpulsecommon-17.0.so + 0x42502)
                #4  0x00007d0b9c20d75c pa_pdispatch_run (libpulsecommon-17.0.so + 0x4375c)
                #5  0x00007d0b9c29b254 n/a (libpulse.so.0 + 0x13254)
                #6  0x00007d0b9c2125d5 n/a (libpulsecommon-17.0.so + 0x485d5)
                #7  0x00007d0b9c21346f n/a (libpulsecommon-17.0.so + 0x4946f)
                #8  0x00007d0b9c2aefc8 pa_mainloop_dispatch (libpulse.so.0 + 0x26fc8)
                #9  0x00007d0b9c2af62b pa_mainloop_iterate (libpulse.so.0 + 0x2762b)
                #10 0x00007d0b9c2af6d1 pa_mainloop_run (libpulse.so.0 + 0x276d1)
                #11 0x00007d0b9c2bfbf2 n/a (libpulse.so.0 + 0x37bf2)
                #12 0x00007d0b9c2262b7 n/a (libpulsecommon-17.0.so + 0x5c2b7)
                #13 0x00007d0b9bca955a n/a (libc.so.6 + 0x8b55a)
                #14 0x00007d0b9bd26a3c n/a (libc.so.6 + 0x108a3c)

                Stack trace of thread 823:
                #0  0x00007d0b9bca5ebe n/a (libc.so.6 + 0x87ebe)
                #1  0x00007d0b9bca8750 pthread_cond_wait (libc.so.6 + 0x8a750)
                #2  0x00007d0b9c2bcaad pa_threaded_mainloop_wait (libpulse.so.0 + 0x34aad)
                #3  0x0000585f5aa75af9 n/a (sway-audio-idle-inhibit + 0x3af9)
                #4  0x0000585f5aa75cf4 n/a (sway-audio-idle-inhibit + 0x3cf4)
                #5  0x0000585f5aa7447c main (sway-audio-idle-inhibit + 0x247c)
                #6  0x00007d0b9bc43cd0 n/a (libc.so.6 + 0x25cd0)
                #7  0x00007d0b9bc43d8a __libc_start_main (libc.so.6 + 0x25d8a)
                #8  0x0000585f5aa746f5 n/a (sway-audio-idle-inhibit + 0x26f5)
                ELF object binary architecture: AMD x86-64
Kagukara commented 6 months ago

Please re-open, I'm still having reproducible crashes if I turn off my screen and turn it back on a while later. I'm on the version from https://github.com/ErikReider/SwayAudioIdleInhibit/pull/14 comment: https://github.com/ErikReider/SwayAudioIdleInhibit/issues/7#issuecomment-1937090370

I am experiencing this as well, sway-audio-idle-inhibit seems to just stop running and turning off my screen/sleep might be the problem as norpol as experienced.

Version: aur/sway-audio-idle-inhibit-git [Installed: 0.1.1.r43.8ac8608-1]

EDIT: Had sway-audio-idle-inhibit running in the terminal and it just randomly Segmentation fault (core dumped). I'll see if I can't get more information on the segfault.

Kagukara commented 6 months ago

I have been running gdb sway-audio-idle-inhibit and watching youtube and stuff via mpv, with nothing happening. As soon as I launched a game which I use gamescope with (doesn't have to be with gamescope) it Segmentation fault (core dumped) with:

Thread 2 "threaded-ml" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff72006c0 (LWP 127550)]
__strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:287

and the backtrace:

(gdb) bt
#0  __strcmp_avx2 () at ../sysdeps/x86_64/multiarch/strcmp-avx2.S:287
#1  0x0000555555557859 in ?? ()
#2  0x00007ffff7f5b2e0 in context_get_source_output_info_callback (pd=<optimized out>, command=<optimized out>, tag=<optimized out>, t=0x7ffff0002b20, userdata=0x55555557e540)
    at ../pulseaudio/src/pulse/introspect.c:1369
#3  0x00007ffff7ec0502 in run_action (pd=0x7ffff00018c0, r=0x55555557e5a0, command=2, ts=0x7ffff0002b20) at ../pulseaudio/src/pulsecore/pdispatch.c:291
#4  0x00007ffff7ec175c in pa_pdispatch_run (pd=0x7ffff00018c0, packet=packet@entry=0x7ffff0003df0, ancil_data=ancil_data@entry=0x7ffff0000f28, userdata=userdata@entry=0x5555555748e0)
    at ../pulseaudio/src/pulsecore/pdispatch.c:344
#5  0x00007ffff7f4f254 in pstream_packet_callback (p=<optimized out>, packet=0x7ffff0003df0, ancil_data=0x7ffff0000f28, userdata=0x5555555748e0) at ../pulseaudio/src/pulse/context.c:364
#6  0x00007ffff7ec65d5 in do_read (p=p@entry=0x7ffff0000c90, re=re@entry=0x7ffff0000e10) at ../pulseaudio/src/pulsecore/pstream.c:1032
#7  0x00007ffff7ec746f in do_pstream_read_write (p=0x7ffff0000c90) at ../pulseaudio/src/pulsecore/pstream.c:265
#8  0x00007ffff7f62fc8 in dispatch_pollfds (m=0x55555556d3b0) at ../pulseaudio/src/pulse/mainloop.c:676
#9  pa_mainloop_dispatch (m=m@entry=0x55555556d3b0) at ../pulseaudio/src/pulse/mainloop.c:917
#10 0x00007ffff7f6362b in pa_mainloop_iterate (m=m@entry=0x55555556d3b0, block=block@entry=1, retval=retval@entry=0x0) at ../pulseaudio/src/pulse/mainloop.c:948
#11 0x00007ffff7f636d1 in pa_mainloop_run (m=0x55555556d3b0, retval=0x0) at ../pulseaudio/src/pulse/mainloop.c:963
#12 0x00007ffff7f73bf2 in thread (userdata=0x55555556d360) at ../pulseaudio/src/pulse/thread-mainloop.c:101
#13 0x00007ffff7eda2b7 in internal_thread_func (userdata=0x55555556d5b0) at ../pulseaudio/src/pulsecore/thread-posix.c:81
#14 0x00007ffff7aa955a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007ffff7b26a3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

Hope this helps.

EDIT: Launching or having OBS up/in tray causes this 100% of the time for me.

nitrotol commented 6 months ago

Have the same behaviour as @gokberkkocak Core dump below

           PID: 102343 (sway-audio-idle)
           UID: 1000 (nitrotol)
           GID: 1000 (nitrotol)
        Signal: 11 (SEGV)
     Timestamp: Mon 2024-03-04 18:21:42 EET (12min ago)
  Command Line: sway-audio-idle-inhibit
    Executable: /usr/bin/sway-audio-idle-inhibit
 Control Group: /user.slice/user-1000.slice/session-2.scope
          Unit: session-2.scope
         Slice: user-1000.slice
       Session: 2
     Owner UID: 1000 (nitrotol)
       Boot ID: b1a2ef1f71cb49ab8294c1c13e248ad9
    Machine ID: 8783bc1abdf445f898bcbe4866041355
      Hostname: nitrotol-thinkpad
       Storage: /var/lib/systemd/coredump/core.sway-audio-idle.1000.b1a2ef1f71cb49ab8294c1c13e248ad9.102343.17095>
  Size on Disk: 211.9K
       Message: Process 102343 (sway-audio-idle) of user 1000 dumped core.

                Stack trace of thread 102344:
                #0  0x00007e3784587942 n/a (libc.so.6 + 0x169942)
                #1  0x00005cc75bfd3859 _ZN5Pulse27source_output_info_callbackEP10pa_contextPK21pa_source_output_i>
                #2  0x00007e37849e72e0 n/a (libpulse.so.0 + 0x1f2e0)
                #3  0x00007e378494c502 n/a (libpulsecommon-17.0.so + 0x42502)
                #4  0x00007e378494d75c pa_pdispatch_run (libpulsecommon-17.0.so + 0x4375c)
                #5  0x00007e37849db254 n/a (libpulse.so.0 + 0x13254)
                #6  0x00007e37849525d5 n/a (libpulsecommon-17.0.so + 0x485d5)
                #7  0x00007e3784953398 n/a (libpulsecommon-17.0.so + 0x49398)
                #8  0x00007e378495378b n/a (libpulsecommon-17.0.so + 0x4978b)
                #9  0x00007e378495798a n/a (libpulsecommon-17.0.so + 0x4d98a)
                #10 0x00007e37849eefc8 pa_mainloop_dispatch (libpulse.so.0 + 0x26fc8)
                #11 0x00007e37849ef62b pa_mainloop_iterate (libpulse.so.0 + 0x2762b)
                #12 0x00007e37849ef6d1 pa_mainloop_run (libpulse.so.0 + 0x276d1)
                #13 0x00007e37849ffbf2 n/a (libpulse.so.0 + 0x37bf2)
                #14 0x00007e37849662b7 n/a (libpulsecommon-17.0.so + 0x5c2b7)
                #15 0x00007e37844a955a n/a (libc.so.6 + 0x8b55a)
                #16 0x00007e3784526a3c n/a (libc.so.6 + 0x108a3c)

                Stack trace of thread 102343:
                #0  0x00007e37844a5ebe n/a (libc.so.6 + 0x87ebe)
                #1  0x00007e37844a8750 pthread_cond_wait (libc.so.6 + 0x8a750)
                #2  0x00007e37849fcaad pa_threaded_mainloop_wait (libpulse.so.0 + 0x34aad)
                #3  0x00005cc75bfd3af9 _ZN5Pulse10getRunningE9EventTypeP4DataP10pa_context (sway-audio-idle-inhib>
                #4  0x00005cc75bfd3cf4 _ZN5Pulse7connectEP20pa_threaded_mainloopP15pa_mainloop_api16SubscriptionT>
                #5  0x00005cc75bfd247c main (sway-audio-idle-inhibit + 0x247c)
                #6  0x00007e3784443cd0 n/a (libc.so.6 + 0x25cd0)
                #7  0x00007e3784443d8a __libc_start_main (libc.so.6 + 0x25d8a)
                #8  0x00005cc75bfd26f5 _start (sway-audio-idle-inhibit + 0x26f5)
                ELF object binary architecture: AMD x86-64
Maksym-L commented 5 months ago

Got the same issue. Here GDB backtrace:

(gdb) bt
#0  __strcmp_evex () at ../sysdeps/x86_64/multiarch/strcmp-evex.S:318
#1  0x000063cd44c21859 in Pulse::source_output_info_callback (i=0x7269f0fff890, userdata=0x63cd46841740)
    at ../SwayAudioIdleInhibit/src/pulse.cpp:49
#2  0x00007269f22a52e0 in context_get_source_output_info_callback (pd=<optimized out>, command=<optimized out>, tag=<optimized out>,
    t=0x7269ec002b20, userdata=0x63cd46852540) at ../pulseaudio/src/pulse/introspect.c:1369
#3  0x00007269f220a502 in run_action (pd=0x7269ec0018c0, r=0x63cd468525a0, command=2, ts=0x7269ec002b20)
    at ../pulseaudio/src/pulsecore/pdispatch.c:291
#4  0x00007269f220b75c in pa_pdispatch_run (pd=0x7269ec0018c0, packet=packet@entry=0x7269ec003df0,
    ancil_data=ancil_data@entry=0x7269ec000f28, userdata=userdata@entry=0x63cd46848b10) at ../pulseaudio/src/pulsecore/pdispatch.c:344
#5  0x00007269f2299254 in pstream_packet_callback (p=<optimized out>, packet=0x7269ec003df0, ancil_data=0x7269ec000f28,
    userdata=0x63cd46848b10) at ../pulseaudio/src/pulse/context.c:364
#6  0x00007269f22105d5 in do_read (p=p@entry=0x7269ec000c90, re=re@entry=0x7269ec000e10) at ../pulseaudio/src/pulsecore/pstream.c:1032
#7  0x00007269f221146f in do_pstream_read_write (p=0x7269ec000c90) at ../pulseaudio/src/pulsecore/pstream.c:265
#8  0x00007269f22acfc8 in dispatch_pollfds (m=0x63cd468413b0) at ../pulseaudio/src/pulse/mainloop.c:676
#9  pa_mainloop_dispatch (m=m@entry=0x63cd468413b0) at ../pulseaudio/src/pulse/mainloop.c:917
#10 0x00007269f22ad62b in pa_mainloop_iterate (m=m@entry=0x63cd468413b0, block=block@entry=1, retval=retval@entry=0x0)
    at ../pulseaudio/src/pulse/mainloop.c:948
#11 0x00007269f22ad6d1 in pa_mainloop_run (m=0x63cd468413b0, retval=0x0) at ../pulseaudio/src/pulse/mainloop.c:963
#12 0x00007269f22bdbf2 in thread (userdata=0x63cd46841360) at ../pulseaudio/src/pulse/thread-mainloop.c:101
#13 0x00007269f22242b7 in internal_thread_func (userdata=0x63cd468415b0) at ../pulseaudio/src/pulsecore/thread-posix.c:81
#14 0x00007269f1ca955a in start_thread (arg=<optimized out>) at pthread_create.c:447
#15 0x00007269f1d26a3c in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Maksym-L commented 5 months ago

I found the issue! It's a bug in the compiler, lol 😅

The culprit is found by inspecting local variables for the failed call:

#1  0x000063cd44c21859 in Pulse::source_output_info_callback (i=0x7269f0fff890, userdata=0x63cd46841740)
    at ../SwayAudioIdleInhibit/src/pulse.cpp:49
(gdb) info locals
i = <optimized out>
appName = 0x7269ec00a140 "PulseAudio Volume Control"
data = 0x63cd46841740
ignoreSourceOutput = false

The suspicion falls on the i = <optimized out> line because if we inspect the call arguments, we would see another i variable:

(gdb) info args
i = 0x7269f0fff890
userdata = 0x63cd46841740

It looks like the i at line 47 is completely removed by the compiler due to "optimization", screwing index access for the ignoredSourceOutputs array:

      int i = 0;
      while (data->ignoredSourceOutputs[i] != nullptr) {

Source: https://github.com/ErikReider/SwayAudioIdleInhibit/blob/main/src/pulse.cpp#L47

I'm not skilled enough in CPP to fix it myself :(

Maksym-L commented 5 months ago

I found another issue: the memory is not initialized: https://github.com/ErikReider/SwayAudioIdleInhibit/blob/main/src/main.cpp#L34

Should be:

char* ignoredSourceOutputs[MAX_IGNORED_SOURCE_OUTPUTS] = { nullptr };

P.S. I'm working on PR

braun-steven commented 1 month ago

Not amazing, but as a workaround, I've just thrown this into a systemd unit and have it auto restart on failure--works "perfect" 😆

Thanks -- for anyone else in need of a systemd service file:

[Unit]
Description=Sway Audio Idle Inhibit
After=sway.service

[Service]
ExecStart=/usr/local/bin/sway-audio-idle-inhibit
Restart=always
RestartSec=5

[Install]
WantedBy=default.target

(set ExecStart to the output of which sway-audio-idle-inhibit).

Save in .config/systemd/user/sway-audio-idle-inhibit.service and enable with

systemctl --user enable --now sway-audio-idle-inhibit