Has anyone else run into issues with the mic_demo_direct demo? I've encountered segmentation faults when modifying the demo (such as adding variables, etc.) that I haven't been able to explain.
So I enabled debug builds in cmake (setting CMAKE_BUILD_TYPE to Debug) for mic_demo_direct and the matrix_creator_hal library, and then I ran gdb to see where the segmentation fault was occurring. It took me to line 40 of demos/mic_demo_direct.cpp. Stepping through, the MicrophoneArray is initialized with enable_beamforming = true and proceeds on to the MicrophoneArray::CalculateDelays() method.
In CalculateDelays() (cpp/driver/microphonearray.cpp), it goes to line 122. The segfault happens here, where the bus pointer (cpp/driver/matrixdriver.h:32) references an invalid address. If I run gdb with the unmodified demo it will continue to run, but with bus referencing an uninitialized MatrixIOBus.
Basically, it seems the root of the issue is that if the MicrophoneArray constructor is run with beamforming enabled then MicrophoneArray ends up trying to call MatrixIOBus::MatrixLeds() using an unset bus pointer. This happens before the bus can be initialized with MicrophoneArray::Setup().
Has anyone else run into issues with the mic_demo_direct demo? I've encountered segmentation faults when modifying the demo (such as adding variables, etc.) that I haven't been able to explain.
So I enabled debug builds in cmake (setting
CMAKE_BUILD_TYPE
to Debug) for mic_demo_direct and the matrix_creator_hal library, and then I ran gdb to see where the segmentation fault was occurring. It took me to line 40 of demos/mic_demo_direct.cpp. Stepping through, the MicrophoneArray is initialized withenable_beamforming = true
and proceeds on to the MicrophoneArray::CalculateDelays() method.In CalculateDelays() (cpp/driver/microphonearray.cpp), it goes to line 122. The segfault happens here, where the bus pointer (cpp/driver/matrixdriver.h:32) references an invalid address. If I run gdb with the unmodified demo it will continue to run, but with bus referencing an uninitialized MatrixIOBus.
Basically, it seems the root of the issue is that if the MicrophoneArray constructor is run with beamforming enabled then MicrophoneArray ends up trying to call MatrixIOBus::MatrixLeds() using an unset bus pointer. This happens before the bus can be initialized with MicrophoneArray::Setup().