IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.61k stars 4.83k forks source link

Valgrind: Conditional jump or move depends on uninitialised value(s) #3433

Closed s-trinh closed 3 years ago

s-trinh commented 5 years ago
Required Info
Camera Model D435
Firmware Version 05.11.01.100
Operating System & Version Ubuntu 16.04
Kernel Version (Linux Only) 4.15.0-46-generic
Platform PC
Language C++

Issue Description

Maybe it is just some false positives but I get Conditional jump or move depends on uninitialised value(s) errors with the following code and latest librealsense:

// License: Apache 2.0. See LICENSE file in root directory.
// Copyright(c) 2017 Intel Corporation. All Rights Reserved.

#include <iostream>
#include <librealsense2/rs.hpp> // Include RealSense Cross Platform API

// Capture Example demonstrates how to
// capture depth and color video streams and render them to the screen
int main(int argc, char * argv[]) try
{
    rs2::log_to_console(RS2_LOG_SEVERITY_ERROR);

    // Declare RealSense pipeline, encapsulating the actual device and sensors
    rs2::pipeline pipe;

    // Start streaming with default recommended configuration
    // The default video configuration contains Depth and Color streams
    // If a device is capable to stream IMU data, both Gyro and Accelerometer are enabled by default
    pipe.start();

    rs2::frameset data = pipe.wait_for_frames();    // Wait for next set of frames from the camera

    return EXIT_SUCCESS;
}
catch (const rs2::error & e)
{
    std::cerr << "RealSense error calling " << e.get_failed_function() << "(" << e.get_failed_args() << "):\n    " << e.what() << std::endl;
    return EXIT_FAILURE;
}
catch (const std::exception& e)
{
    std::cerr << e.what() << std::endl;
    return EXIT_FAILURE;
}

Log:

``` ==21538== Memcheck, a memory error detector ==21538== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==21538== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info ==21538== Command: ./rs-capture -v --track-origins=yes ==21538== ==21538== Syscall param epoll_ctl(event) points to uninitialised byte(s) ==21538== at 0x77579BA: epoll_ctl (syscall-template.S:84) ==21538== by 0x61C47E3: perc::Poller::add(perc::Poller::event const&) (Poller_lin.cpp:53) ==21538== by 0x61BEE47: perc::Dispatcher::Dispatcher() (Dispatcher.cpp:14) ==21538== by 0x6175E58: perc::Manager::Manager(perc::TrackingManager::Listener*, void*) (Manager.cpp:68) ==21538== by 0x6175B79: perc::TrackingManager::CreateInstance(perc::TrackingManager::Listener*, void*) (Manager.cpp:39) ==21538== by 0x5EB8DC7: librealsense::tm2_context::create_manager() (tm-context.cpp:30) ==21538== by 0x5F2802B: librealsense::context::query_devices(int) const (context.cpp:315) ==21538== by 0x5EF85E1: librealsense::device_hub::device_hub(std::shared_ptr, int, int, bool) (device_hub.cpp:37) ==21538== by 0x5E7D666: librealsense::pipeline::pipeline::pipeline(std::shared_ptr) (pipeline.cpp:18) ==21538== by 0x6036CF3: _ZN9__gnu_cxx13new_allocatorIN12librealsense8pipeline8pipelineEE9constructIS3_IRSt10shared_ptrINS1_7contextEEEEEvPT_DpOT0_ (new_allocator.h:120) ==21538== by 0x603568B: _ZNSt16allocator_traitsISaIN12librealsense8pipeline8pipelineEEE9constructIS2_IRSt10shared_ptrINS0_7contextEEEEEvRS3_PT_DpOT0_ (alloc_traits.h:530) ==21538== by 0x6033A5B: std::_Sp_counted_ptr_inplace, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace&>(std::allocator, std::shared_ptr&) (shared_ptr_base.h:522) ==21538== Address 0x1ffeffe888 is on thread 1's stack ==21538== in frame #1, created by perc::Poller::add(perc::Poller::event const&) (Poller_lin.cpp:43) ==21538== ==21538== Thread 10: ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B26A2A: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_capture_timing const*) const (metadata-parser.h:147) ==21538== by 0x5B24EAE: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B7D782: librealsense::rs435_device::create_matcher(librealsense::frame_holder const&) const (ds5-factory.cpp:691) ==21538== by 0x5F955D4: librealsense::composite_matcher::find_matcher(librealsense::frame_holder const&) (sync.cpp:179) ==21538== by 0x5F9509C: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:146) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== by 0x5E1564B: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:39) ==21538== by 0x5E7EEE0: librealsense::pipeline::pipeline::get_callback(std::vector >)::{lambda(librealsense::frame_holder)#3}::operator()(librealsense::frame_holder) const (pipeline.cpp:208) ==21538== by 0x5E86A73: librealsense::internal_frame_callback >)::{lambda(librealsense::frame_holder)#3}>::on_frame(rs2_frame*) (types.h:900) ==21538== by 0x60576DE: librealsense::frame_source::invoke_callback(librealsense::frame_holder) const (source.cpp:125) ==21538== ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B27B87: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::_M_lower_bound(std::_Rb_tree_node, std::allocator > > > const*, std::_Rb_tree_node, std::allocator > > > const*, librealsense::md_type const&) const (stl_tree.h:1644) ==21538== by 0x5B27907: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::find(librealsense::md_type const&) const (stl_tree.h:2308) ==21538== by 0x5B2765B: std::map, std::allocator >, std::less, std::allocator, std::allocator > > > >::count(librealsense::md_type const&) const (stl_map.h:892) ==21538== by 0x5B26A57: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_capture_timing const*) const (metadata-parser.h:149) ==21538== by 0x5B24EAE: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B7D782: librealsense::rs435_device::create_matcher(librealsense::frame_holder const&) const (ds5-factory.cpp:691) ==21538== by 0x5F955D4: librealsense::composite_matcher::find_matcher(librealsense::frame_holder const&) (sync.cpp:179) ==21538== by 0x5F9509C: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:146) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== by 0x5E1564B: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:39) ==21538== ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B2795C: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::find(librealsense::md_type const&) const (stl_tree.h:2311) ==21538== by 0x5B2765B: std::map, std::allocator >, std::less, std::allocator, std::allocator > > > >::count(librealsense::md_type const&) const (stl_map.h:892) ==21538== by 0x5B26A57: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_capture_timing const*) const (metadata-parser.h:149) ==21538== by 0x5B24EAE: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B7D782: librealsense::rs435_device::create_matcher(librealsense::frame_holder const&) const (ds5-factory.cpp:691) ==21538== by 0x5F955D4: librealsense::composite_matcher::find_matcher(librealsense::frame_holder const&) (sync.cpp:179) ==21538== by 0x5F9509C: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:146) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== by 0x5E1564B: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:39) ==21538== by 0x5E7EEE0: librealsense::pipeline::pipeline::get_callback(std::vector >)::{lambda(librealsense::frame_holder)#3}::operator()(librealsense::frame_holder) const (pipeline.cpp:208) ==21538== ==21538== Use of uninitialised value of size 8 ==21538== at 0x71B9B61: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21538== by 0x71BB1BB: std::ostreambuf_iterator > std::num_put > >::_M_insert_int(std::ostreambuf_iterator >, std::ios_base&, char, unsigned long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21538== by 0x71BB36C: std::num_put > >::do_put(std::ostreambuf_iterator >, std::ios_base&, char, unsigned long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21538== by 0x71C7699: std::ostream& std::ostream::_M_insert(unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21538== by 0x5B277C5: librealsense::to_string& librealsense::to_string::operator<< (unsigned int const&) (types.h:88) ==21538== by 0x5B26B17: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_capture_timing const*) const (metadata-parser.h:151) ==21538== by 0x5B24EAE: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B7D782: librealsense::rs435_device::create_matcher(librealsense::frame_holder const&) const (ds5-factory.cpp:691) ==21538== by 0x5F955D4: librealsense::composite_matcher::find_matcher(librealsense::frame_holder const&) (sync.cpp:179) ==21538== by 0x5F9509C: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:146) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x71B9B68: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21538== by 0x71BB1BB: std::ostreambuf_iterator > std::num_put > >::_M_insert_int(std::ostreambuf_iterator >, std::ios_base&, char, unsigned long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21538== by 0x71BB36C: std::num_put > >::do_put(std::ostreambuf_iterator >, std::ios_base&, char, unsigned long) const (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21538== by 0x71C7699: std::ostream& std::ostream::_M_insert(unsigned long) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==21538== by 0x5B277C5: librealsense::to_string& librealsense::to_string::operator<< (unsigned int const&) (types.h:88) ==21538== by 0x5B26B17: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_capture_timing const*) const (metadata-parser.h:151) ==21538== by 0x5B24EAE: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B7D782: librealsense::rs435_device::create_matcher(librealsense::frame_holder const&) const (ds5-factory.cpp:691) ==21538== by 0x5F955D4: librealsense::composite_matcher::find_matcher(librealsense::frame_holder const&) (sync.cpp:179) ==21538== by 0x5F9509C: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:146) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B67CF8: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_depth_control const*) const (metadata-parser.h:147) ==21538== by 0x5B66D2A: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B3F290: librealsense::ds5_md_attribute_actual_fps::get(librealsense::frame const&) const (metadata-parser.h:307) ==21538== by 0x5EFFEC3: librealsense::frame::get_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:227) ==21538== by 0x5F981D6: librealsense::timestamp_composite_matcher::update_last_arrived(librealsense::frame_holder&, librealsense::matcher*) (sync.cpp:501) ==21538== by 0x5F950D5: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:147) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== by 0x5E1564B: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:39) ==21538== by 0x5E7EEE0: librealsense::pipeline::pipeline::get_callback(std::vector >)::{lambda(librealsense::frame_holder)#3}::operator()(librealsense::frame_holder) const (pipeline.cpp:208) ==21538== by 0x5E86A73: librealsense::internal_frame_callback >)::{lambda(librealsense::frame_holder)#3}>::on_frame(rs2_frame*) (types.h:900) ==21538== ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B27B87: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::_M_lower_bound(std::_Rb_tree_node, std::allocator > > > const*, std::_Rb_tree_node, std::allocator > > > const*, librealsense::md_type const&) const (stl_tree.h:1644) ==21538== by 0x5B27907: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::find(librealsense::md_type const&) const (stl_tree.h:2308) ==21538== by 0x5B2765B: std::map, std::allocator >, std::less, std::allocator, std::allocator > > > >::count(librealsense::md_type const&) const (stl_map.h:892) ==21538== by 0x5B67D25: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_depth_control const*) const (metadata-parser.h:149) ==21538== by 0x5B66D2A: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B3F290: librealsense::ds5_md_attribute_actual_fps::get(librealsense::frame const&) const (metadata-parser.h:307) ==21538== by 0x5EFFEC3: librealsense::frame::get_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:227) ==21538== by 0x5F981D6: librealsense::timestamp_composite_matcher::update_last_arrived(librealsense::frame_holder&, librealsense::matcher*) (sync.cpp:501) ==21538== by 0x5F950D5: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:147) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B2795C: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::find(librealsense::md_type const&) const (stl_tree.h:2311) ==21538== by 0x5B2765B: std::map, std::allocator >, std::less, std::allocator, std::allocator > > > >::count(librealsense::md_type const&) const (stl_map.h:892) ==21538== by 0x5B67D25: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_depth_control const*) const (metadata-parser.h:149) ==21538== by 0x5B66D2A: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B3F290: librealsense::ds5_md_attribute_actual_fps::get(librealsense::frame const&) const (metadata-parser.h:307) ==21538== by 0x5EFFEC3: librealsense::frame::get_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:227) ==21538== by 0x5F981D6: librealsense::timestamp_composite_matcher::update_last_arrived(librealsense::frame_holder&, librealsense::matcher*) (sync.cpp:501) ==21538== by 0x5F950D5: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:147) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== by 0x5E1564B: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:39) ==21538== ==21538== Thread 11: ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B75920: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_rgb_control const*) const (metadata-parser.h:147) ==21538== by 0x5B75894: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B3F290: librealsense::ds5_md_attribute_actual_fps::get(librealsense::frame const&) const (metadata-parser.h:307) ==21538== by 0x5EFFEC3: librealsense::frame::get_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:227) ==21538== by 0x5F981D6: librealsense::timestamp_composite_matcher::update_last_arrived(librealsense::frame_holder&, librealsense::matcher*) (sync.cpp:501) ==21538== by 0x5F950D5: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:147) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== by 0x5E1564B: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:39) ==21538== by 0x5E7EEE0: librealsense::pipeline::pipeline::get_callback(std::vector >)::{lambda(librealsense::frame_holder)#3}::operator()(librealsense::frame_holder) const (pipeline.cpp:208) ==21538== by 0x5E86A73: librealsense::internal_frame_callback >)::{lambda(librealsense::frame_holder)#3}>::on_frame(rs2_frame*) (types.h:900) ==21538== ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B27B87: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::_M_lower_bound(std::_Rb_tree_node, std::allocator > > > const*, std::_Rb_tree_node, std::allocator > > > const*, librealsense::md_type const&) const (stl_tree.h:1644) ==21538== by 0x5B27907: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::find(librealsense::md_type const&) const (stl_tree.h:2308) ==21538== by 0x5B2765B: std::map, std::allocator >, std::less, std::allocator, std::allocator > > > >::count(librealsense::md_type const&) const (stl_map.h:892) ==21538== by 0x5B7594D: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_rgb_control const*) const (metadata-parser.h:149) ==21538== by 0x5B75894: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B3F290: librealsense::ds5_md_attribute_actual_fps::get(librealsense::frame const&) const (metadata-parser.h:307) ==21538== by 0x5EFFEC3: librealsense::frame::get_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:227) ==21538== by 0x5F981D6: librealsense::timestamp_composite_matcher::update_last_arrived(librealsense::frame_holder&, librealsense::matcher*) (sync.cpp:501) ==21538== by 0x5F950D5: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:147) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== ==21538== Conditional jump or move depends on uninitialised value(s) ==21538== at 0x5B2795C: std::_Rb_tree, std::allocator > >, std::_Select1st, std::allocator > > >, std::less, std::allocator, std::allocator > > > >::find(librealsense::md_type const&) const (stl_tree.h:2311) ==21538== by 0x5B2765B: std::map, std::allocator >, std::less, std::allocator, std::allocator > > > >::count(librealsense::md_type const&) const (stl_map.h:892) ==21538== by 0x5B7594D: librealsense::md_attribute_parser::is_attribute_valid(librealsense::md_rgb_control const*) const (metadata-parser.h:149) ==21538== by 0x5B75894: librealsense::md_attribute_parser::supports(librealsense::frame const&) const (metadata-parser.h:135) ==21538== by 0x5F00039: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:240) ==21538== by 0x5B3F290: librealsense::ds5_md_attribute_actual_fps::get(librealsense::frame const&) const (metadata-parser.h:307) ==21538== by 0x5EFFEC3: librealsense::frame::get_frame_metadata(rs2_frame_metadata_value const&) const (archive.cpp:227) ==21538== by 0x5F981D6: librealsense::timestamp_composite_matcher::update_last_arrived(librealsense::frame_holder&, librealsense::matcher*) (sync.cpp:501) ==21538== by 0x5F950D5: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment) (sync.cpp:147) ==21538== by 0x5E21D62: librealsense::syncer_process_unit::syncer_process_unit()::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:38) ==21538== by 0x5E24EF9: librealsense::internal_frame_processor_callback::on_frame(rs2_frame*, rs2_source*) (processing.h:63) ==21538== by 0x5E1564B: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:39) ==21538== ==21538== ==21538== HEAP SUMMARY: ==21538== in use at exit: 96,883 bytes in 56 blocks ==21538== total heap usage: 31,849 allocs, 31,793 frees, 25,307,228 bytes allocated ==21538== ==21538== LEAK SUMMARY: ==21538== definitely lost: 96 bytes in 24 blocks ==21538== indirectly lost: 0 bytes in 0 blocks ==21538== possibly lost: 14,759 bytes in 24 blocks ==21538== still reachable: 82,028 bytes in 8 blocks ==21538== suppressed: 0 bytes in 0 blocks ==21538== Rerun with --leak-check=full to see details of leaked memory ==21538== ==21538== For counts of detected and suppressed errors, rerun with: -v ==21538== Use --track-origins=yes to see where uninitialised values come from ==21538== ERROR SUMMARY: 324 errors from 12 contexts (suppressed: 0 from 0) ```
dorodnic commented 5 years ago

Interesting, we need to check these. Thank you for the report

doronhi commented 3 years ago

I tested the latest development version on ubuntu 16.04. I found some memory leaks ("blocks are indirectly lost", "blocks are still reachable", etc.) but no "Conditional jump or move depends on uninitialised value(s)". errors. Tested with both v4l and rsusb backends. My guess is that this issue was fixed with #8875 but maybe it was something else. I opened an internal ticket - LRS-317 - to fix the existing valgrind errors and warnings.

alexswerner commented 2 years ago

I have at least a similar issue. Here is the valgrind (memcheck) backtrace collected with --track-origins=yes

==15861== Conditional jump or move depends on uninitialised value(s)
==15861==    at 0x957DBE8: librealsense::md_attribute_parser<librealsense::md_depth_control, unsigned int, librealsense::md_depth_control_attributes>::is_attribute_valid(librealsense::md_depth_control const*) const (metadata-parser.h:152)
==15861==    by 0x957C09A: librealsense::md_attribute_parser<librealsense::md_depth_control, unsigned int, librealsense::md_depth_control_attributes>::supports(librealsense::frame const&) const (metadata-parser.h:141)
==15861==    by 0x9C970C0: librealsense::frame::supports_frame_metadata(rs2_frame_metadata_value const&) const (frame.cpp:144)
==15861==    by 0x9537E74: librealsense::ds5_md_attribute_actual_fps::get(librealsense::frame const&) const (metadata-parser.h:352)
==15861==    by 0x9C96E1C: librealsense::frame::get_frame_metadata(rs2_frame_metadata_value const&) const (frame.cpp:117)
==15861==    by 0x9C5974B: librealsense::timestamp_composite_matcher::update_last_arrived(librealsense::frame_holder&, librealsense::matcher*) (sync.cpp:565)
==15861==    by 0x9C56048: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment const&) (sync.cpp:147)
==15861==    by 0x9C5609B: librealsense::composite_matcher::dispatch(librealsense::frame_holder, librealsense::syncronization_environment const&) (sync.cpp:148)
==15861==    by 0x98EF62B: librealsense::syncer_process_unit::syncer_process_unit(std::initializer_list<std::shared_ptr<librealsense::bool_option> >, bool)::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}::operator()(librealsense::frame_holder, librealsense::synthetic_source_interface*) const (syncer-processing-block.cpp:63)
==15861==    by 0x98F36A5: librealsense::internal_frame_processor_callback<librealsense::syncer_process_unit::syncer_process_unit(std::initializer_list<std::shared_ptr<librealsense::bool_option> >, bool)::{lambda(librealsense::frame_holder, librealsense::synthetic_source_interface*)#2}>::on_frame(rs2_frame*, rs2_source*) (processing.h:67)
==15861==    by 0x98DD75F: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:43)
==15861==    by 0x99B344E: librealsense::pipeline::pipeline::get_callback(std::vector<int, std::allocator<int> >)::{lambda(librealsense::frame_holder)#3}::operator()(librealsense::frame_holder) const (pipeline.cpp:215)
==15861==    by 0x99BB89B: librealsense::internal_frame_callback<librealsense::pipeline::pipeline::get_callback(std::vector<int, std::allocator<int> >)::{lambda(librealsense::frame_holder)#3}>::on_frame(rs2_frame*) (types.h:763)
==15861==    by 0x9C0ABBE: librealsense::synthetic_sensor::start(std::shared_ptr<rs2_frame_callback>)::{lambda(librealsense::frame_holder)#1}::operator()(librealsense::frame_holder) const (sensor.cpp:1586)
==15861==    by 0x9C12C85: librealsense::internal_frame_callback<librealsense::synthetic_sensor::start(std::shared_ptr<rs2_frame_callback>)::{lambda(librealsense::frame_holder)#1}>::on_frame(rs2_frame*) (types.h:763)
==15861==    by 0x9C4AFE1: librealsense::frame_source::invoke_callback(librealsense::frame_holder) const (source.cpp:123)
==15861==    by 0x98E0CCC: librealsense::synthetic_source::frame_ready(librealsense::frame_holder) (synthetic-stream.cpp:319)
==15861==    by 0x9B958AA: rs2_synthetic_frame_ready (rs.cpp:1776)
==15861==    by 0x98E95FB: rs2::frame_source::frame_ready(rs2::frame) const (rs_processing.hpp:102)
==15861==    by 0x98DDDD2: librealsense::generic_processing_block::generic_processing_block(char const*)::{lambda(rs2::frame, rs2::frame_source const&)#1}::operator()(rs2::frame, rs2::frame_source const&) const (synthetic-stream.cpp:95)
==15861==    by 0x98E8C12: rs2::frame_processor_callback<librealsense::generic_processing_block::generic_processing_block(char const*)::{lambda(rs2::frame, rs2::frame_source const&)#1}>::on_frame(rs2_frame*, rs2_source*) (rs_processing.hpp:128)
==15861==    by 0x98DD75F: librealsense::processing_block::invoke(librealsense::frame_holder) (synthetic-stream.cpp:43)
==15861==    by 0x9C0AD90: librealsense::synthetic_sensor::start(std::shared_ptr<rs2_frame_callback>)::{lambda(librealsense::frame_holder)#2}::operator()(librealsense::frame_holder) const (sensor.cpp:1611)
==15861==    by 0x9C12BC9: librealsense::internal_frame_callback<librealsense::synthetic_sensor::start(std::shared_ptr<rs2_frame_callback>)::{lambda(librealsense::frame_holder)#2}>::on_frame(rs2_frame*) (types.h:763)
==15861==    by 0x9C4AFE1: librealsense::frame_source::invoke_callback(librealsense::frame_holder) const (source.cpp:123)
==15861==    by 0x9BFE159: librealsense::uvc_sensor::open(std::vector<std::shared_ptr<librealsense::stream_profile_interface>, std::allocator<std::shared_ptr<librealsense::stream_profile_interface> > > const&)::{lambda(librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void ()>)#1}::operator()(librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void ()>) (sensor.cpp:433)
==15861==    by 0x9C0CF9E: std::_Function_handler<void (librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void ()>), librealsense::uvc_sensor::open(std::vector<std::shared_ptr<librealsense::stream_profile_interface>, std::allocator<std::shared_ptr<librealsense::stream_profile_interface> > > const&)::{lambda(librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void ()>)#1}>::_M_invoke(std::_Any_data const&, librealsense::platform::stream_profile&&, librealsense::platform::frame_object&&, std::function<void ()>&&) (std_function.h:316)
==15861==    by 0x9888481: std::function<void (librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void ()>)>::operator()(librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void ()>) const (std_function.h:706)
==15861==    by 0x9A432EE: librealsense::platform::v4l_uvc_device::poll() (backend-v4l2.cpp:1102)
==15861==    by 0x9A455D7: librealsense::platform::v4l_uvc_device::capture_loop() (backend-v4l2.cpp:1469)
==15861==    by 0x9A4157A: librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}::operator()() const (backend-v4l2.cpp:809)
==15861==    by 0x9A4A618: void std::__invoke_impl<void, librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}>(std::__invoke_other, librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}&&) (invoke.h:60)
==15861==    by 0x9A4910C: std::__invoke_result<librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}>::type std::__invoke<librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}>(std::__invoke_result&&, (librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}&&)...) (invoke.h:95)
==15861==    by 0x9A4D9F7: decltype (__invoke((_S_declval<0ul>)())) std::thread::_Invoker<std::tuple<librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) (thread:234)
==15861==    by 0x9A4D9B3: std::thread::_Invoker<std::tuple<librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}> >::operator()() (thread:243)
==15861==    by 0x9A4D983: std::thread::_State_impl<std::thread::_Invoker<std::tuple<librealsense::platform::v4l_uvc_device::stream_on(std::function<void (librealsense::notification const&)>)::{lambda()#1}> > >::_M_run() (thread:186)
==15861==    by 0xAF7B6DE: ??? (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25)
==15861==    by 0x56EB6DA: start_thread (pthread_create.c:463)
==15861==    by 0x5A2471E: clone (clone.S:95)
==15861==  Uninitialised value was created by a stack allocation
==15861==    at 0x9BFC61B: librealsense::sensor_base::generate_frame_from_data(librealsense::platform::frame_object const&, librealsense::frame_timestamp_reader*, double const&, unsigned long long const&, std::shared_ptr<librealsense::stream_profile_interface>) (sensor.cpp:267)
==15861==

Interestingly this issue only shows up in valgrind within a bigger codebase, so far I have not managed to recreate it with a minimal example.

After a little bit of investigation, my guess was that the problem lies here in the frame additional_data constructor

struct frame_additional_data : frame_header
{
...
std::array<uint8_t, MAX_META_DATA_SIZE> metadata_blob;
...
    frame_additional_data( rs2_time_t in_timestamp,
                           unsigned long long in_frame_number,
                           rs2_time_t in_system_time,
                           uint8_t md_size,
                           const uint8_t * md_buf,
                           rs2_time_t backend_time,
                           rs2_time_t last_timestamp,
                           unsigned long long last_frame_number,
                           bool in_is_blocking,
                           float in_depth_units = 0,
                           uint32_t transmitted_size = 0 )
        : frame_header( in_timestamp, in_frame_number, in_system_time, backend_time )
        , metadata_size( md_size )
        , last_timestamp( last_timestamp )
        , last_frame_number( last_frame_number )
        , is_blocking( in_is_blocking )
        , depth_units( in_depth_units )
        , raw_size( transmitted_size )
    {
        // Copy up to 255 bytes to preserve metadata as raw data
        if( metadata_size )
            std::copy( md_buf, md_buf + std::min( md_size, MAX_META_DATA_SIZE ), metadata_blob.begin() );
    }
}

std::copy only initializes part of the buffer metadata_blob. In use this then later shows up in valgrind. In sensors.hpp as a stack allocation:

    std::shared_ptr<frame> sensor_base::generate_frame_from_data(const platform::frame_object& fo,
        frame_timestamp_reader* timestamp_reader,
        const rs2_time_t& last_timestamp,
        const unsigned long long& last_frame_number,
        std::shared_ptr<stream_profile_interface> profile)
    {
        ....

        frame_additional_data additional_data(0,
            0,
            system_time,
            static_cast<uint8_t>(fo.metadata_size),
            (const uint8_t*)fo.metadata,
            fo.backend_time,
            last_timestamp,
            last_frame_number,
            false,
            0,
            (uint32_t)fo.frame_size);

        if (_metadata_modifier)
            _metadata_modifier(additional_data);
        fr->additional_data = additional_data;
        ....

After adding std::array::fill to the constructor

     metadata_blob.fill(0);
     if( metadata_size )
            std::copy( md_buf, md_buf + std::min( md_size, MAX_META_DATA_SIZE ), metadata_blob.begin() );

valgrind is completely satisfied. However the call still fails, with the same error:

RealSense error calling rs2_get_frame_metadata

It seems to work now, but i'm not sure if this actually fixed the underlying issue.

Version info: