sdrpp-tetra-demodulator icon indicating copy to clipboard operation
sdrpp-tetra-demodulator copied to clipboard

[Segmentation - Sanitize err] Crash on voice - mac m1

Open bastienjalbert opened this issue 6 months ago • 0 comments

Hello, thank you cropinghigh for your plugins, wonderful !

I have an issue on mac silicon which does not seem to happen on ubuntu (same commit compilation for both sdrpp and tetra plugin). The stack trace bellow. It looks like to be something with static void put_voice_data(void* ctx, int count, int16_t* data) function, because if I comment out the code, I can see VOICE on SDRPP but it's not crashing (but no audio, indeed).

The code in put_voice_data is very simple, I can't figure out why there is a BUS error here

AddressSanitizer:DEADLYSIGNAL
=================================================================
==45126==ERROR: AddressSanitizer: BUS on unknown address (pc 0x0001872f5d74 bp 0x0001774c89a0 sp 0x0001774c8980 T56)
==45126==The signal is caused by a READ memory access.
==45126==Hint: this fault was caused by a dereference of a high value address (see register values below).  Disassemble the provided pc to learn which register was used.
    #0 0x1872f5d74 in ___chkstk_darwin+0x3c (libsystem_pthread.dylib:arm64e+0x1d74)
    #1 0x1530a3728 in tp_sap_udata_ind tetra_lower_mac.c:370.  ------> line 370 is put_voice_data() call
    #2 0x1530a48ac in tetra_burst_rx_cb tetra_burst.c:380
    #3 0x1530a4b5c in tetra_burst_sync_in tetra_burst_sync.c:134
    #4 0x1530b40d8 in dsp::osmotetradec::run() osmotetra_dec.h:201
    #5 0x101be27f4 in dsp::block::workerLoop() block.h:68
    #6 0x1530a7d54 in void* std::__1::__thread_proxy[abi:ue170006]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, void (dsp::block::*)(), dsp::block*>>(void*) thread.h:238
    #7 0x1872faf90 in _pthread_start+0x84 (libsystem_pthread.dylib:arm64e+0x6f90)
    #8 0x1872f5d30 in thread_start+0x4 (libsystem_pthread.dylib:arm64e+0x1d30)

==45126==Register values:
 x[0] = 0x000000010e4bbd78   x[1] = 0x00000000000001e0   x[2] = 0x00000001774c8ad2   x[3] = 0x0000000000000027  
 x[4] = 0x00000001530cc070   x[5] = 0x0000000000000001   x[6] = 0x00000001774c872e   x[7] = 0x00000001774c872c  
 x[8] = 0x00000001530b76dc   x[9] = 0x00000000003d0910  x[10] = 0x00000001770f8070  x[11] = 0x0000000177448000  
x[12] = 0x000000702a639840  x[13] = 0x0000000000000000  x[14] = 0x000000702a63981e  x[15] = 0x0000000341a2a9d0  
x[16] = 0x00000001872f5d38  x[17] = 0x00000001009605e8  x[18] = 0x0000000000000000  x[19] = 0x00000001041bbcc0  
x[20] = 0x0000000317ad0580  x[21] = 0x000000034007a480  x[22] = 0x00000001530cd184  x[23] = 0x00000001774c8cb2  
x[24] = 0x0000000000000000  x[25] = 0x00000001774c8ad2  x[26] = 0x00000001774caa40  x[27] = 0x000000000000010c  
x[28] = 0x00000001774cab44     fp = 0x00000001774c89a0     lr = 0x00000001530b7700     sp = 0x00000001774c8980  
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: BUS (libsystem_pthread.dylib:arm64e+0x1d74) in ___chkstk_darwin+0x3c
Thread T56 created by T0 here:
    #0 0x100907d6c in wrap_pthread_create+0x54 (libclang_rt.asan_osx_dynamic.dylib:arm64e+0x4bd6c)
    #1 0x1530a7ca8 in std::__1::thread::thread<void (dsp::block::*)(), dsp::block*, void>(void (dsp::block::*&&)(), dsp::block*&&) thread.h:254
    #2 0x1530a786c in dsp::block::doStart() block.h:72
    #3 0x1530af648 in TetraDemodulatorModule::setMode() main.cpp:186
    #4 0x1530ade68 in TetraDemodulatorModule::TetraDemodulatorModule(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) main.cpp:109
    #5 0x1530ac97c in _CREATE_INSTANCE_ main.cpp:487
    #6 0x101bd8f80 in ModuleManager::createInstance(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>) module.cpp:102
    #7 0x101a895e0 in MainWindow::init() main_window.cpp:141
    #8 0x101a507e4 in sdrpp_main(int, char**) core.cpp:370
    #9 0x10006bf8c in main main.cpp:4
    #10 0x186f720dc  (<unknown module>)

==45126==ABORTING

put_voice_data reminder code :

static void put_voice_data(void* ctx, int count, int16_t* data) {
      osmotetradec* _this = (osmotetradec*) ctx;
      // if I comment lines after, no BUS error but no audio (indeed)
      float conv_data[STREAM_BUFFER_SIZE];
      volk_16i_s32f_convert_32f(conv_data, data, 32768.0f, count);
      if(_this->out_tmp_buff.getWritable(false) >= count) {
          _this->out_tmp_buff.write(conv_data, count);
      }
 }

bastienjalbert avatar Aug 23 '24 20:08 bastienjalbert