matrix-creator-hal icon indicating copy to clipboard operation
matrix-creator-hal copied to clipboard

MicrophoneArray segmentation fault

Open glhahn opened this issue 4 years ago • 1 comments

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/microphone_array.cpp), it goes to line 122. The segfault happens here, where the bus_ pointer (cpp/driver/matrix_driver.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().

glhahn avatar Oct 03 '20 01:10 glhahn

Hi, I have the same error with the direction_of_arrival_demo_direct. thanks for the info, i will try to debug it.

fpgasdr avatar Feb 03 '21 23:02 fpgasdr