[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#980472: cubicsdr: CubicSDR crashes after lauch! (same effect on 2 clean bullseye OS)



Control: reassign -1 libhamlib4 4.0-6
Control: fixed -1 4.1-1
Control: affects -1 cubicsdr
Control: forwarded -1 https://sourceforge.net/p/hamlib/code/ci/31dedcf4f79d8fc5fcf287360e5d017842c8e4c0/

On Sat, Mar 06, 2021 at 06:18:43PM +0100, Bernhard Übelacker wrote:
> Dear Maintainer,
> I found this interesting and tried to reproduce inside
> a minimal VM and it crashed.
> 
> 
> > > Hmm. Can exit() lead to segfaults in threaded programs?
> 
> It looks like it does. exit() would call __run_exit_handlers, that
> might to run some destructors while the other thread is at least
> in my example still in SoapySSDPEndpoint::getServerURLs.
> 
> 
> I tried to track down why the exit is called in the first place
> and I guess this is because rig_load_all_backends is called twice.
> 
> First once here:
>     #2  0x00007fcd9fbdc655 in rig_load_all_backends () at ../../src/register.c:459
>     #3  0x0000562467ef9177 in RigThread::enumerate() () at ./src/rig/RigThread.cpp:26
>     #4  0x0000562467ddf0b4 in CubicSDR::OnInit() (this=0x5624680dc910) at ./src/CubicSDR.cpp:259
>     #5  0x00007fcd9f12da72 in wxEntry(int&, wchar_t**) () at /lib/x86_64-linux-gnu/libwx_baseu-3.0.so.0
>     #6  0x0000562467dd6c02 in main(int, char**) (argc=<optimized out>, argv=<optimized out>) at ./src/CubicSDR.cpp:28
> https://github.com/cjcliffe/CubicSDR/blob/master/src/rig/RigThread.cpp#L28
> 
> 
> And second in another thread from here:
>     ...
>     #6  0x00007fcd9fbdc655 in rig_load_all_backends () at ../../src/register.c:459
>     #7  0x00007fcd8400f1cf in findAudio(SoapySDR::Kwargs const&) () at ./Registration.cpp:90
>     ...
>     #25 ... (SoapySSDPEndpoint::*)(int, long), SoapySSDPEndpoint*, int, long> >&&)::{lambda()#1}> > >::_M_run() (this=0x7fcd880018a0) at /usr/include/c++/10/thread:215
>     #28 0x00007fcd9ec1ced0 in std::execute_native_thread_routine(void*) (__p=0x56246ac320d0) at ../../../../../src/libstdc++-v3/src/c++11/thread.cc:80
>     #29 0x00007fcd9e9d6ea7 in start_thread (arg=<optimized out>) at pthread_create.c:477
>     #30 0x00007fcd9e906def in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
> https://github.com/pothosware/SoapyAudio/blob/master/Registration.cpp#L90
> Seems originating from the global static initialization
> in Registration.cpp:112, which is done in threads for some reason.
> 
> 
> Therefore in the second call the rig_hash_table
> is already populated and the exit is called.
> 
> And due to the threaded nature the crash could
> happen at different places.

The oneline fix for hamlib above matches your analysis exactly.

> Kind regards,
> Bernhard

cu
Adrian


Reply to: