Bug#980472: cubicsdr: CubicSDR crashes after lauch! (same effect on 2 clean bullseye OS)
- To: Bernhard Übelacker <bernhardu@mailbox.org>, 980472@bugs.debian.org
- Cc: Louis HB <louis.hb@bluewin.ch>, Christoph Berg <myon@debian.org>, Benjamin Bänziger <helios.solaris@gmx.ch>
- Subject: Bug#980472: cubicsdr: CubicSDR crashes after lauch! (same effect on 2 clean bullseye OS)
- From: Adrian Bunk <bunk@debian.org>
- Date: Tue, 1 Jun 2021 02:06:33 +0300
- Message-id: <[🔎] 20210531230633.GA7425@localhost>
- Reply-to: Adrian Bunk <bunk@debian.org>, 980472@bugs.debian.org
- In-reply-to: <4e8ef307-413b-ecd4-2e35-a71530dc5a8d@mailbox.org>
- References: <YAnvLJFdQz0fFc1Y@msg.df7cb.de> <0f1aea26-f522-ae70-0bc7-66b619a1846a@bluewin.ch> <24be7bc6-3838-121b-1c17-82a6b9ffc711@bluewin.ch> <YArWnkVKQVQM6xCj@msg.df7cb.de> <6ca20665-509f-227b-0474-c354b701e5e5@bluewin.ch> <6ca20665-509f-227b-0474-c354b701e5e5@bluewin.ch> <161106752736.1967.9659302872389093380.reportbug@pc-168.home> <4e8ef307-413b-ecd4-2e35-a71530dc5a8d@mailbox.org> <161106752736.1967.9659302872389093380.reportbug@pc-168.home>
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: