Closed eddsalkield closed 5 months ago
Build and install a debug build and get a more precise backtrace.
I've installed a debug build, and got the following trace:
Thread 1 "sdrpp" received signal SIGILL, Illegal instruction.
0x00007ffff79c806a in dsp::filter::FIR<dsp::complex_t, float>::setTaps(dsp::tap<float>&) () from /usr/lib/libsdrpp_core.so
(gdb) bt
#0 0x00007ffff79c806a in dsp::filter::FIR<dsp::complex_t, float>::setTaps(dsp::tap<float>&) () from /usr/lib/libsdrpp_core.so
#1 0x00007ffff79d64ef in dsp::channel::RxVFO::setOutSamplerate(double, double) () from /usr/lib/libsdrpp_core.so
#2 0x00007ffff79d52c0 in VFOManager::VFO::setSampleRate(double, double) () from /usr/lib/libsdrpp_core.so
#3 0x00007fffd0a83766 in RadioModule::selectDemod(demod::Demodulator*) () from /usr/lib/sdrpp/plugins/radio.so
#4 0x00007fffd0a83a98 in RadioModule::selectDemodByID(RadioModule::DemodID) () from /usr/lib/sdrpp/plugins/radio.so
#5 0x00007fffd0a85719 in RadioModule::RadioModule(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) () from /usr/lib/sdrpp/plugins/radio.so
#6 0x00007fffd0a65316 in _CREATE_INSTANCE_ () from /usr/lib/sdrpp/plugins/radio.so
#7 0x00007ffff79c016f in ModuleManager::createInstance(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) () from /usr/lib/libsdrpp_core.so
#8 0x00007ffff790221c in MainWindow::init() () from /usr/lib/libsdrpp_core.so
#9 0x00007ffff78e92b2 in sdrpp_main(int, char**) () from /usr/lib/libsdrpp_core.so
#10 0x000055555555517f in ?? ()
#11 0x00007ffff7f786d1 in libc_start_main_stage2 (main=0x555555555175, argc=1, argv=0x7fffffffe8c8) at src/env/__libc_start_main.c:95
#12 0x0000555555555046 in ?? ()
#13 0x0000000000000001 in ?? ()
#14 0x00007fffffffeb97 in ?? ()
#15 0x0000000000000000 in ?? ()
For some reason the symbols got stripped in the previous reply, here's the complete backtrace:
Thread 1 "sdrpp" received signal SIGILL, Illegal instruction.
dsp::filter::FIR<dsp::complex_t, float>::setTaps (this=this@entry=0x7fffd1080818, taps=...)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/core/src/signal_path/../dsp/multirate/../filter/fir.h:47
47 memcpy(&buffer[_taps.size - oldTC], buffer, (oldTC - 1) * sizeof(D));
(gdb) bt full
#0 dsp::filter::FIR<dsp::complex_t, float>::setTaps (this=this@entry=0x7fffd1080818,
taps=...)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/core/src/signal_path/../dsp/multirate/../filter/fir.h:47
__func__ = "setTaps"
lck = {_M_device = @0x7fffd1080828}
oldTC = 76
#1 0x00007ffff79d64ef in dsp::channel::RxVFO::setOutSamplerate (this=0x7fffd10800b0,
outSamplerate=outSamplerate@entry=250000, bandwidth=bandwidth@entry=150000)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/core/src/signal_path/../dsp/channel/rx_vfo.h:55
__func__ = "setOutSamplerate"
lck = {_M_device = @0x7fffd10800c0}
#2 0x00007ffff79d52c0 in VFOManager::VFO::setSampleRate (this=0x7fffcf9e2d70,
sampleRate=sampleRate@entry=250000, bandwidth=150000)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/core/src/signal_path/vfo_manager.cpp:52
No locals.
#3 0x00007fffd0c77766 in RadioModule::selectDemod (this=this@entry=0x7fffc898c4c0,
demod=<optimized out>)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/decoder_modules/radio/src/radio_module.h:421
ifSamplerate = 250000
#4 0x00007fffd0c77a98 in RadioModule::selectDemodByID (this=this@entry=0x7fffc898c4c0,
id=<optimized out>)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/decoder_modules/radio/src/radio_module.h:329
startTime = {__d = {__r = 1713297636490676523}}
demod = <optimized out>
endTime = {__d = {__r = 0}}
#5 0x00007fffd0c79719 in RadioModule::RadioModule (this=0x7fffc898c4c0, name=...)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/decoder_modules/radio/src/radio_module.h:97
created = <optimized out>
created = <optimized out>
#6 0x00007fffd0c59316 in _CREATE_INSTANCE_ (name=...)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/decoder_modules/radio/src/main.cpp:19
No locals.
#7 0x00007ffff79c016f in ModuleManager::createInstance (
this=0x7ffff7a74280 <core::moduleManager>, name=..., module=...)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/core/src/module.cpp:102
maxCount = -1
inst = {module = {handle = 0x7fffe1716d40, info = 0x7fffd0c98d20 <_INFO_>,
init = 0x7fffd0c5937d <_INIT_()>,
--Type <RET> for more, q to quit, c to continue without paging--c
createInstance = 0x7fffd0c592d7 <_CREATE_INSTANCE_(std::string)>,
deleteInstance = 0x7fffd0c592b7 <_DELETE_INSTANCE_(void*)>,
end = 0x7fffd0c59115 <_END_()>}, instance = 0x7fffffffe340}
#8 0x00007ffff790221c in MainWindow::init (this=0x7ffff7e47400 <gui::mainWindow>)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/core/src/gui/main_window.cpp:141
mod = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffffffe490 "radio"}, _M_string_length = 5, {
_M_local_buf = "radio\000p_source\000",
_M_allocated_capacity = 6876997109504303474}}
enabled = true
_module = <optimized out>
__for_range = @0x7fffffffe3a8: {container = @0x7ffff6ba94f0}
__for_begin = {anchor = {m_object = 0x7ffff6ba94f0, m_it = {object_iterator = {
_M_node = 0x7ffff6b83510}, array_iterator = {_M_current = 0x0},
primitive_iterator = {static begin_value = 0, static end_value = 1,
m_it = -9223372036854775808}}}, array_index = 16, array_index_last = 0,
array_index_str = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffffffe560 "0"}, _M_string_length = 1, {
_M_local_buf = "0\000\316\341\377\177\000\000\202\r\370\367\377\177\000",
_M_allocated_capacity = 140736981762096}}, empty_str = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffffffe580 ""}, _M_string_length = 0, {
_M_local_buf = "\000\000\000\000\000\000\000\000\210\346\377\377\377\177\000",
_M_allocated_capacity = 0}}}
__for_end = {anchor = {m_object = 0x7ffff6ba94f0, m_it = {object_iterator = {
_M_node = 0x7ffff6b57d68}, array_iterator = {_M_current = 0x0},
primitive_iterator = {static begin_value = 0, static end_value = 1,
m_it = -9223372036854775808}}}, array_index = 0, array_index_last = 0,
array_index_str = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffffffe5d0 "0"}, _M_string_length = 1, {
_M_local_buf = "0\000\377\377\377\177\000\000\000\261\357\340\377\177\000",
_M_allocated_capacity = 140737488289840}}, empty_str = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffffffe5f0 ""}, _M_string_length = 0, {
_M_local_buf = "\000\037\316\341\377\177\000\000\v\000\256\227\310\002\354", <incomplete sequence \363>, _M_allocated_capacity = 140736981769984}}}
name = @0x7ffff6b83530: {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7ffff6b83540 "Radio"}, _M_string_length = 5, {
_M_local_buf = "Radio\000\000\000\000\000\000\000\000\000\000",
_M_allocated_capacity = 478509556050}}
menuElements = {m_type = nlohmann::detail::value_t::array, m_value = {
object = 0x7fffe2995d70, array = 0x7fffe2995d70, string = 0x7fffe2995d70,
binary = 0x7fffe2995d70, boolean = 112, number_integer = 140736995089776,
number_unsigned = 140736995089776, number_float = 6.9533314372786523e-310}}
modulesDir = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffe0ebc770 "/usr/local/lib/sdrpp/plugins"},
_M_string_length = 28, {
_M_local_buf = "\034\000\000\000\000\000\000\000@\347\377\377\377\177\000",
_M_allocated_capacity = 28}}
resourcesDir = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7fffe0e94a40 "/usr/local/share/sdrpp"},
_M_string_length = 22, {
_M_local_buf = "\026\000\000\000\000\000\000\000\220\035\316\341\377\177\000",
_M_allocated_capacity = 22}}
modules = {<std::_Vector_base<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >> = {
_M_impl = {<std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<std::__new_allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >> = {<No data fields>}, <No data fields>}, <std::_Vector_base<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::_Vector_impl_data> = {_M_start = 0x0, _M_finish = 0x0,
_M_end_of_storage = 0x0}, <No data fields>}}, <No data fields>}
modList = {container = @0x7ffff6ba94f0}
frequency = <optimized out>
finalBwHalf = <optimized out>
#9 0x00007ffff78e92b2 in sdrpp_main (argc=<optimized out>, argv=<optimized out>)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/core/src/core.cpp:370
serverMode = <optimized out>
root = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7ffff6ee3990 "/home/edd/.config/sdrpp"},
_M_string_length = 23, {
_M_local_buf = "\027\000\000\000\000\000\000\000`\330\377\367\000\000\000",
_M_allocated_capacity = 23}}
defConfig = {m_type = nlohmann::detail::value_t::object, m_value = {
object = 0x7ffff6aa3e10, array = 0x7ffff6aa3e10, string = 0x7ffff6aa3e10,
binary = 0x7ffff6aa3e10, boolean = 16, number_integer = 140737331740176,
number_unsigned = 140737331740176, number_float = 6.9533480700183822e-310}}
items = {container = @0x7ffff7a74340}
resDir = {
_M_dataplus = {<std::allocator<char>> = {<std::__new_allocator<char>> = {<No data fields>}, <No data fields>}, _M_p = 0x7ffff6e99ce0 "/usr/local/share/sdrpp"},
_M_string_length = 22, {
_M_local_buf = "\026\000\000\000\000\000\000\000erver\000\000",
_M_allocated_capacity = 22}}
bandColors = {m_type = nlohmann::detail::value_t::object, m_value = {
object = 0x7ffff6b57ae0, array = 0x7ffff6b57ae0, string = 0x7ffff6b57ae0,
binary = 0x7ffff6b57ae0, boolean = 224, number_integer = 140737332476640,
number_unsigned = 140737332476640, number_float = 6.9533481064045384e-310}}
biRes = <optimized out>
#10 0x000055555555517f in main (argc=<optimized out>, argv=<optimized out>)
at /home/edd/dev/aports/testing/sdr++/src/SDRPlusPlus-e118598f5763d29862cc3ff143e23a36868bffe4/src/main.cpp:5
No locals.
How did you compile it? Was the cmakelist modified? Did you change compile arguments? The fact it crashes on a memcpy with an illegal instruction exception sounds a lot like it was compiled for vector extensions that your CPU does not support.
I compiled it using the following:
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DOPT_BUILD_USRP_SOURCE=ON \
-DOPT_BUILD_PLUTOSDR_SOURCE=0
I slightly changed a CMakeList to disable asan, which is not supported under musl libc:
diff old/core/libcorrect/CMakeLists.txt new/core/libcorrect/CMakeLists.txt
--- old/core/libcorrect/CMakeLists.txt
+++ new/core/libcorrect/CMakeLists.txt
@@ -17,14 +17,8 @@
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
- # On android, keep optimisations and don't use asan
- if (ANDROID)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O3")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,")
- else()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0 -fsanitize=address")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie,")
- endif()
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -O0")
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-no_pie,")
else()
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
Further poking in the assembly layout of GDB shows that the precise CPU instruction that causes the failure happens on instruction ud2
.
This seems to be a specifically undefined instruction, which is confusing.
| 0x7ffff79c805d <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+263> mov $0x0,%edx │
│ 0x7ffff79c8062 <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+268> call *0x9ec28(%rip) # 0x7ffff7a66c90 │
│ 0x7ffff79c8068 <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+274> jmp 0x7ffff79c8005 <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+175> │
│ >0x7ffff79c806a <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+276> ud2 │
│ 0x7ffff79c806c <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+278> mov %r12,%rdi
It's preceded by a non conditional jump instructions so the undefined instruction after it is not surprising.
You should look at what the code its jumping to looks like.
afaict, we're jumping here:
│ 0x7ffff79c7ffd <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+167> jb 0x7ffff79c8010 <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+186> │
│ 0x7ffff79c7fff <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+169> call *0x9ed9b(%rip) # 0x7ffff7a66da0 │
│ 0x7ffff79c8005 <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+175> mov %rbx,%rdi │
│ 0x7ffff79c8008 <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+178> call *0xa0b02(%rip) # 0x7ffff7a68b10 │
│ 0x7ffff79c800e <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+184> jmp 0x7ffff79c806c <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+278> │
│ 0x7ffff79c8010 <_ZN3dsp6filter3FIRINS_9complex_tEfE7setTapsERNS_3tapIfEE+186> ud2 │
Looks like it should be jumping back to 0x7ffff79c806c
after the call, but somehow we end up at 0x7ffff79c806a
instead, which is our ud2
. I can't think of why - do you have any ideas? I suppose it must be jumping to 0x7ffff79c806a
from somewhere else.
Thanks so much for your help, btw
I'm not sure. I think the only way to figure this out is to put a breakpoint a bit before when it happens and step instruction by instruction nothing the exact program flow along the way.
More digging with gdb revealed that the following section of /usr/include/fortify/string.h
from the fortify-headers package was detecting overlapping pointers for the memcpy, which is UB.
The fix would be to use std::copy, which is defined for when the destination iterator is outside the range to be copied, even if the ranges overlap.
I've fixed it in this patch https://github.com/eddsalkield/SDRPlusPlus/commit/4ba2ad3f4bb1c0a9da5abc89109848851eb7e861, which I was going to submit as a PR, but apparently that's unwelcome. What do you think of the patch?
Ngl, that package should probably not just outright crash software with an illegal instruction... This is probably the least debuggable way to report such a fault...
std::copy
is no good due to C++ bloat. The correct solution is to use memmove
instead. I'll push a fix.
Should be fixed, let me know if not.
We're now starting correctly, thanks!
Hardware
Software
Bug Description
sdrpp
crashes on startup when loading the Radio module with exceptionIllegal instruction
.Steps To Reproduce
sdrpp
Additional info Backtrace: