ouster-lidar / ouster_example

Ouster, Inc. sample code
Other
448 stars 432 forks source link

Latest release of Ouster SDK causes segmentation fault in examples/lidar_scan_example.cpp #569

Open arunumd opened 7 months ago

arunumd commented 7 months ago

Describe the bug If you try to compile and run the examples/lidar_scan_example.cpp with a pcap and a json file, it causes a SIGSEGV, Segmentation fault

To Reproduce Steps to reproduce the behavior (steps below are just an example):

  1. compile the example using cmake --build . --target lidar_scan_example
  2. run the code as sudo ./examples/lidar_scan_example $PCAP_FILE_NAME $JSON_FILE_NAME
  3. observe the issue like below
arun@arun:~/ouster_example/build$ sudo ./examples/lidar_scan_example 2_meter.pcap 2_meter.json
[2023-11-16 11:28:27.319] [ouster::sensor] [info] parsing non-legacy metadata format
Creating scans from pcap... Scans created!                                                   

Printing first element of received scan headers                                              
        frame_id : 60332                                                                     
        ts : 9577253683288                                                                   
        status : 1                                                                           
        measurement_id : 0                                                                   

Printing range of pixel at 15th row and 498th column...                                      
        range(15, 498): 0                                                                    
Accessing field that isn't available... ..received expected out of range error. Continuing...

Let's see what's in each of these scans!                                                     
Available fields in Legacy Scan...                                                           
        RANGE                                                                                
        SIGNAL                                                                               
        NEAR_IR                                                                              
        REFLECTIVITY                                                                         

Available fields in Profile Scan...
        RANGE
        SIGNAL
        REFLECTIVITY
        NEAR_IR

Available fields in Dual Returns Scan...
        RANGE
        RANGE2
        SIGNAL
        SIGNAL2
        REFLECTIVITY
        REFLECTIVITY2
        NEAR_IR

Available fields in Reduced fields Scan...
        RANGE
        NEAR_IR

Segmentation fault (core dumped)

Screenshots Refer the terminal log above

Platform (please complete the following information):

Note: For your convenience I am also attaching the json file created by the sensor when I created the pcap recording using the ouster-cli tool.

This is the json file : 2_meter.json

Additional Info (Maybe useful): ouster-sdk 0.9.0 was used for recording the pcap file with the ouster-cli tool

arunumd commented 7 months ago

The Segmentation fault issue does not happen in this commit : 9d0971107f6f9c95e16afd727fa2534d01a0fe4e

twslankard commented 7 months ago

Thanks for the report @arunumd . Unfortunately, I'm not able to reproduce the issue.

Cheers,

Tom Staff Engineer Ouster Inc.

arunumd commented 7 months ago

The -DCMAKE_BUILD_TYPE=Debug flag does not seem to generate a core dump.

Regarding the problematic pcap file, can you please consult Michael Turner?

arunumd commented 7 months ago

I am unable to get a core dump in my WSL1 environment. It seems like a limitation of WSL1. So I ran Address Sanitizer using

add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)

inside this CMakeLists.txt file, and then cmake .. -DBUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=ASAN .

This is the diagnostics I get from ASAN

arun@arun:~/ouster_example/build$ sudo ./examples/lidar_scan_example 2_meter.pcap 2_meter.json
[2023-11-20 10:18:38.041] [ouster::sensor] [info] parsing non-legacy metadata format
AddressSanitizer:DEADLYSIGNAL
=================================================================
==31884==ERROR: AddressSanitizer: SEGV on unknown address 0xfffffffffffffff1 (pc 0x7f09c7dacb3f bp 0x000000000000 sp 0x7fffd63c02a0 T0)
==31884==The signal is caused by a READ memory access.
    #0 0x7f09c7dacb3e in bool __sanitizer::atomic_compare_exchange_strong<__sanitizer::atomic_uint8_t>(__sanitizer::atomic_uint8_t volatile*, __sanitizer::atomic_uint8_t::Type*, __sani
tizer::atomic_uint8_t::Type, __sanitizer::memory_order) ../../../../src/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:79
    #1 0x7f09c7dacb3e in __asan::Allocator::AtomicallySetQuarantineFlagIfAllocated(__asan::AsanChunk*, void*, __sanitizer::BufferedStackTrace*) ../../../../src/libsanitizer/asan/asan_a
llocator.cc:552
    #2 0x7f09c7dacb3e in __asan::Allocator::Deallocate(void*, unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType) ../../../../src/libsanitizer/asan/asan_
allocator.cc:629
    #3 0x7f09c7dacb3e in __asan::asan_delete(void*, unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType) ../../../../src/libsanitizer/asan/asan_allocator.
/ouster_example/build/examples/lidar_scan_example+0x15b8b)
    #13 0x7f09c883d46b in std::_Optional_base<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, false, false>::~_Optional_base() (/home/arun/oust
er_example/build/examples/lidar_scan_example+0x1546b)
    #14 0x7f09c883d48b in std::optional<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >::~optional() (/home/arun/ouster_example/build/examples
/lidar_scan_example+0x1548b)
    #15 0x7f09c883d537 in ouster::sensor::sensor_config::~sensor_config() (/home/arun/ouster_example/build/examples/lidar_scan_example+0x15537)
    #16 0x7f09c88620b5 in ouster::sensor::sensor_info::sensor_info(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) /home/arun/oust
er_example/ouster_client/src/sensor_info.cpp:504
    #17 0x7f09c886760e in ouster::sensor::parse_metadata(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) /home/arun/ouster_example
/ouster_client/src/sensor_info.cpp:994
    #18 0x7f09c8867109 in ouster::sensor::metadata_from_json(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) /home/arun/ouster_exa
mple/ouster_client/src/sensor_info.cpp:973
    #19 0x7f09c883b96b in main /home/arun/ouster_example/examples/lidar_scan_example.cpp:37
    #20 0x7f09c7574082 in __libc_start_main ../csu/libc-start.c:308
    #21 0x7f09c883afad in _start (/home/arun/ouster_example/build/examples/lidar_scan_example+0x12fad)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../../../../src/libsanitizer/sanitizer_common/sanitizer_atomic_clang.h:79 in bool __sanitizer::atomic_compare_exchange_strong<__sanitizer::atomic_uint8_
t>(__sanitizer::atomic_uint8_t volatile*, __sanitizer::atomic_uint8_t::Type*, __sanitizer::atomic_uint8_t::Type, __sanitizer::memory_order)
==31884==ABORTING

The line 37 it is talking about is this line : https://github.com/ouster-lidar/ouster_example/blob/master/examples/lidar_scan_example.cpp#L37

It seems like it is having some issues parsing the metadata from the JSON file.

twslankard commented 7 months ago

The JSON file parsed fine when I tried it. I'll see if I can get the PCAP from Michael. Thanks for the additional info!

Cheers,

Tom Staff Engineer Ouster Inc.

Sridhar701Pitt commented 6 months ago

I have the same Segmentation fault (core dumped) error with 20231031 release. Here are the json and pcap files I tested with. testA.zip

Environment: Using a docker container (ubuntu 22.04 | cuda 12.1 | cmake 3.28.1) dockerfile.zip