g0orx / linhpsdr

Linux HPSDR
GNU General Public License v3.0
74 stars 44 forks source link

Crash when microphone is selected #104

Open hellmind opened 3 years ago

hellmind commented 3 years ago

linhpsdr latest build crash if I enable my microphone, fish: Job 1, 'linhpsdr' terminated by signal SIGSEGV (Address boundary error)

Maybe; [690253:690253:0622/171735.325212:ERROR:gl_utils.cc(314)] [.RendererMainThread-0x3638f1822500] GL_INVALID_FRAMEBUFFER_OPERATION: Draw framebuffer is incomplete

`jun 22 17:38:49 arch systemd-coredump[2668084]: [🡕] Process 2648955 (linhpsdr) of user 1000 dumped core.

                                            Stack trace of thread 2648991:
                                            #0  0x00007f7287448d25 pa_hashmap_get (libpulsecommon-14.2.so + 0x27d25)
                                            #1  0x00007f7288a8b73d n/a (libpulse.so.0 + 0x2e73d)
                                            #2  0x00007f7287462c31 pa_pdispatch_run (libpulsecommon-14.2.so + 0x41c31)
                                            #3  0x00007f7288a6fad1 n/a (libpulse.so.0 + 0x12ad1)
                                            #4  0x00007f72874660df n/a (libpulsecommon-14.2.so + 0x450df)
                                            #5  0x00007f7287467bbf n/a (libpulsecommon-14.2.so + 0x46bbf)
                                            #6  0x00007f7288a83c23 pa_mainloop_dispatch (libpulse.so.0 + 0x26c23)
                                            #7  0x00007f7288a84291 pa_mainloop_iterate (libpulse.so.0 + 0x27291)
                                            #8  0x00007f7288a84331 pa_mainloop_run (libpulse.so.0 + 0x27331)
                                            #9  0x00007f7288a947fe n/a (libpulse.so.0 + 0x377fe)
                                            #10 0x00007f72874775cc n/a (libpulsecommon-14.2.so + 0x565cc)
                                            #11 0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #12 0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648974:
                                            #0  0x00007f7289bed8ca __futex_abstimed_wait_common64 (libpthread.so.0 + 0x158ca)
                                            #1  0x00007f7289be9ae8 __new_sem_wait_slow64.constprop.0 (libpthread.so.0 + 0x11ae8)
                                            #2  0x00007f7289ac2ae0 wdspmain (libwdsp.so + 0x3cae0)
                                            #3  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #4  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648973:
                                            #0  0x00007f7288046b2f __poll (libc.so.6 + 0xf3b2f)
                                            #1  0x00007f7288a90654 n/a (libpulse.so.0 + 0x33654)
                                            #2  0x00007f7288a799a9 pa_mainloop_poll (libpulse.so.0 + 0x1c9a9)
                                            #3  0x00007f7288a84281 pa_mainloop_iterate (libpulse.so.0 + 0x27281)
                                            #4  0x00007f7288a84331 pa_mainloop_run (libpulse.so.0 + 0x27331)
                                            #5  0x00007f7288a947fe n/a (libpulse.so.0 + 0x377fe)
                                            #6  0x00007f72874775cc n/a (libpulsecommon-14.2.so + 0x565cc)
                                            #7  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #8  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648957:
                                            #0  0x00007f7288046b2f __poll (libc.so.6 + 0xf3b2f)
                                            #1  0x00007f7288c4ab29 n/a (libglib-2.0.so.0 + 0xa7b29)
                                            #2  0x00007f7288bf6693 g_main_loop_run (libglib-2.0.so.0 + 0x53693)
                                            #3  0x00007f7288e338c8 n/a (libgio-2.0.so.0 + 0x1018c8)
                                            #4  0x00007f7288c252c1 n/a (libglib-2.0.so.0 + 0x822c1)
                                            #5  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #6  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648955:
                                            #0  0x00007f72880b678e __memmove_avx_unaligned_erms (libc.so.6 + 0x16378e)
                                            #1  0x0000557dc733a636 update_waterfall (linhpsdr + 0x30636)
                                            #2  0x0000557dc73265c3 update_timer_cb (linhpsdr + 0x1c5c3)
                                            #3  0x00007f7288bf76b4 n/a (libglib-2.0.so.0 + 0x546b4)
                                            #4  0x00007f7288bf7015 g_main_context_dispatch (libglib-2.0.so.0 + 0x54015)
                                            #5  0x00007f7288c4ab99 n/a (libglib-2.0.so.0 + 0xa7b99)
                                            #6  0x00007f7288bf4871 g_main_context_iteration (libglib-2.0.so.0 + 0x51871)
                                            #7  0x00007f7288dfe8b6 g_application_run (libgio-2.0.so.0 + 0xcc8b6)
                                            #8  0x0000557dc731b3f6 main (linhpsdr + 0x113f6)
                                            #9  0x00007f7287f7ab25 __libc_start_main (libc.so.6 + 0x27b25)
                                            #10 0x0000557dc731b46e _start (linhpsdr + 0x1146e)

                                            Stack trace of thread 2648994:
                                            #0  0x00007f7289bed8ca __futex_abstimed_wait_common64 (libpthread.so.0 + 0x158ca)
                                            #1  0x00007f7289be7270 pthread_cond_wait@@GLIBC_2.3.2 (libpthread.so.0 + 0xf270)
                                            #2  0x00007f7288a91739 pa_threaded_mainloop_wait (libpulse.so.0 + 0x34739)
                                            #3  0x00007f7288ab4a51 pa_simple_read (libpulse-simple.so.0 + 0x2a51)
                                            #4  0x0000557dc731d182 mic_read_thread (linhpsdr + 0x13182)
                                            #5  0x00007f7288c252c1 n/a (libglib-2.0.so.0 + 0x822c1)
                                            #6  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #7  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648992:
                                            #0  0x00007f7289bed8ca __futex_abstimed_wait_common64 (libpthread.so.0 + 0x158ca)
                                            #1  0x00007f7289be9ae8 __new_sem_wait_slow64.constprop.0 (libpthread.so.0 + 0x11ae8)
                                            #2  0x00007f7289ac2ae0 wdspmain (libwdsp.so + 0x3cae0)
                                            #3  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #4  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648993:
                                            #0  0x00007f7288046b2f __poll (libc.so.6 + 0xf3b2f)
                                            #1  0x00007f7288a90654 n/a (libpulse.so.0 + 0x33654)
                                            #2  0x00007f7288a799a9 pa_mainloop_poll (libpulse.so.0 + 0x1c9a9)
                                            #3  0x00007f7288a84281 pa_mainloop_iterate (libpulse.so.0 + 0x27281)
                                            #4  0x00007f7288a84331 pa_mainloop_run (libpulse.so.0 + 0x27331)
                                            #5  0x00007f7288a947fe n/a (libpulse.so.0 + 0x377fe)
                                            #6  0x00007f72874775cc n/a (libpulsecommon-14.2.so + 0x565cc)
                                            #7  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #8  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648996:
                                            #0  0x00007f7288019a95 clock_nanosleep@@GLIBC_2.17 (libc.so.6 + 0xc6a95)
                                            #1  0x00007f728801ec77 __nanosleep (libc.so.6 + 0xcbc77)
                                            #2  0x00007f7288049a99 usleep (libc.so.6 + 0xf6a99)
                                            #3  0x0000557dc733f47a protocol2_timer_thread (linhpsdr + 0x3547a)
                                            #4  0x00007f7288c252c1 n/a (libglib-2.0.so.0 + 0x822c1)
                                            #5  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #6  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648995:
                                            #0  0x00007f7289beaaf2 recvfrom (libpthread.so.0 + 0x12af2)
                                            #1  0x0000557dc733efde protocol2_thread (linhpsdr + 0x34fde)
                                            #2  0x00007f7288c252c1 n/a (libglib-2.0.so.0 + 0x822c1)
                                            #3  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #4  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2649014:
                                            #0  0x00007f7288019a95 clock_nanosleep@@GLIBC_2.17 (libc.so.6 + 0xc6a95)
                                            #1  0x00007f728801ec77 __nanosleep (libc.so.6 + 0xcbc77)
                                            #2  0x00007f7288049a99 usleep (libc.so.6 + 0xf6a99)
                                            #3  0x00007f7289a9c99e sendbuf (libwdsp.so + 0x1699e)
                                            #4  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #5  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2648956:
                                            #0  0x00007f7288046b2f __poll (libc.so.6 + 0xf3b2f)
                                            #1  0x00007f7288c4ab29 n/a (libglib-2.0.so.0 + 0xa7b29)
                                            #2  0x00007f7288bf4871 g_main_context_iteration (libglib-2.0.so.0 + 0x51871)
                                            #3  0x00007f7288bf48c2 n/a (libglib-2.0.so.0 + 0x518c2)
                                            #4  0x00007f7288c252c1 n/a (libglib-2.0.so.0 + 0x822c1)
                                            #5  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #6  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)

                                            Stack trace of thread 2667961:
                                            #0  0x00007f7288019a95 clock_nanosleep@@GLIBC_2.17 (libc.so.6 + 0xc6a95)
                                            #1  0x00007f728801ec77 __nanosleep (libc.so.6 + 0xcbc77)
                                            #2  0x00007f7288049a99 usleep (libc.so.6 + 0xf6a99)
                                            #3  0x00007f7289a9c99e sendbuf (libwdsp.so + 0x1699e)
                                            #4  0x00007f7289be1259 start_thread (libpthread.so.0 + 0x9259)
                                            #5  0x00007f72880515e3 __clone (libc.so.6 + 0xfe5e3)`
hellmind commented 3 years ago

This happen if no pulseaudio card profile is selected.

hellmind commented 3 years ago

Also im having crash if I use pulseaudio, , it seems mic cant be used with pulse. I can select it but afte some tx It crash

SOUNDIO works "fine", but on rx i notice some weird noises

daneenjah commented 2 years ago

I'm having the same issue as well, ended up selling my ANON 7000 because of it.

hellmind commented 2 years ago

This is a problem about pulseaudio and buffer overflow. I must learn how to use those libs to discover where exactly is the bug. I think the problems is that buffer size isn't calculated correctly using every current variables as sample rate.

On Thu, Jul 22, 2021 at 3:42 PM daneenjah @.***> wrote:

I'm having the same issue as well, ended up selling my ANON 7000 because of it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/g0orx/linhpsdr/issues/104#issuecomment-885147354, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABIZ5WYANCG4OOLHVZJC3FLTZBQ7PANCNFSM47ENYBEQ .

andreasdotorg commented 2 years ago

I have found the reason for this crash. When the mic is enabled, both data coming from the ANAN built-in mic port and from pulseaudio are processed. This of course is not only wrong, it also leads to a race condition, since processing protocol 2 data and processing audio data happens in the same thread. Thus, when process_mic_data is being run simultaneously in both threads, it can happen that one thread fills the buffer up, and before it can reset the buffer, the other thread adds to it overwriting the data.

I'll propose a fix.

andreasdotorg commented 2 years ago

BTW, to find the problem, I used clang as a compiler, and -fsanitize=address as build option. This pointed me to process_mic_data as the function overflowing its buffer. The rest was deduction.