-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Random Segmentation Fault when capturing images #4459
Comments
No one to help me ? |
When I run the algorithm I also often have this error: ./RealSense The error can occur on any camera (not one in particular). For information I use a powered USB3 hub. |
Hi @pierreavanzini, It looks the basic query of the device version and info has some trouble per below log.
|
Hi @pierreavanzini, Any update? Is the issue clarified/resolved/ |
Hi @pierreavanzini, |
Issue Description
With an UP board and a USB3 hub, I capture color and depth images from four D435 cameras and my algorithm ends randomly with a segmentation fault (If I only use one camera I have the same problem but the backtrace is a bit different).
Backtrace with 4 devices:
Thread 106 "RealSense" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffaaffd700 (LWP 2730)]
0x00007ffff70303d7 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x7fff70069140) at /usr/include/c++/7/bits/shared_ptr_base.h:154
154 _M_dispose();
(gdb) bt
#0 0x00007ffff70303d7 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x7fff70069140) at /usr/include/c++/7/bits/shared_ptr_base.h:154
#1 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::operator= (__r=..., this=0x7ffff7d21fa8 librealsense::environment::get_instance()::env+200) at /usr/include/c++/7/bits/shared_ptr_base.h:703
#2 std::__shared_ptr<librealsense::platform::time_service, (__gnu_cxx::_Lock_policy)2>::operator= (this=0x7ffff7d21fa0 librealsense::environment::get_instance()::env+192)
at /usr/include/c++/7/bits/shared_ptr_base.h:1034
#3 std::shared_ptrlibrealsense::platform::time_service::operator= (this=0x7ffff7d21fa0 librealsense::environment::get_instance()::env+192) at /usr/include/c++/7/bits/shared_ptr.h:93
#4 librealsense::environment::set_time_service (this=this@entry=0x7ffff7d21ee0 librealsense::environment::get_instance()::env, ts=
std::shared_ptrlibrealsense::platform::time_service (use count 2, weak count 0) = {...}) at /home/up/librealsense/src/environment.cpp:201
#5 0x00007ffff702080d in librealsense::context::context (this=0x7fff7c008d30, type=, filename=, section=0x0, mode=RS2_RECORDING_MODE_COUNT, min_api_version="0.0.0")
at /home/up/librealsense/src/context.cpp:131
#6 0x00007ffff706400f in __gnu_cxx::new_allocatorlibrealsense::context::construct<librealsense::context, librealsense::backend_type> (this=, __p=0x7fff7c008d30)
at /usr/include/c++/7/ext/new_allocator.h:136
#7 std::allocator_traits<std::allocatorlibrealsense::context >::construct<librealsense::context, librealsense::backend_type> (__a=..., __p=)
at /usr/include/c++/7/bits/alloc_traits.h:475
#8 std::_Sp_counted_ptr_inplace<librealsense::context, std::allocatorlibrealsense::context, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplacelibrealsense::backend_type (__a=...,
this=0x7fff7c008d20) at /usr/include/c++/7/bits/shared_ptr_base.h:526
#9 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<librealsense::context, std::allocatorlibrealsense::context, librealsense::backend_type> (__a=..., this=0x7fff7c068e78)
at /usr/include/c++/7/bits/shared_ptr_base.h:637
#10 std::__shared_ptr<librealsense::context, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocatorlibrealsense::context, librealsense::backend_type> (__a=..., __tag=..., this=0x7fff7c068e70)
at /usr/include/c++/7/bits/shared_ptr_base.h:1295
#11 std::shared_ptrlibrealsense::context::shared_ptr<std::allocatorlibrealsense::context, librealsense::backend_type> (__a=..., __tag=..., this=0x7fff7c068e70)
at /usr/include/c++/7/bits/shared_ptr.h:344
#12 std::allocate_shared<librealsense::context, std::allocatorlibrealsense::context, librealsense::backend_type> (__a=...) at /usr/include/c++/7/bits/shared_ptr.h:691
#13 rs2_create_context (api_version=, error=0x7fffaaffcc08) at /usr/include/c++/7/bits/shared_ptr.h:707
#14 0x000055555558aaad in rs2::context::context() ()
#15 0x000055555558c0e6 in CamInfo::CamInfo() ()
#16 0x000055555558c348 in FrameInfo::FrameInfo() ()
#17 0x00005555555871d1 in capture_thread(CamInfo) ()
#18 0x000055555558f40d in void std::__invoke_impl<void, void ()(CamInfo), CamInfo>(std::__invoke_other, void (&&)(CamInfo), CamInfo&&) ()
#19 0x000055555558d5fe in std::__invoke_result<void ()(CamInfo), CamInfo>::type std::__invoke<void ()(CamInfo), CamInfo>(void (&&)(CamInfo), CamInfo&&) ()
#20 0x000055555559755b in decltype (__invoke((_S_declval<0ul>)(), (_S_declval<1ul>)())) std::thread::_Invoker<std::tuple<void ()(CamInfo), CamInfo> >::_M_invoke<0ul, 1ul>(std::_Index_tuple<0ul, 1ul>) ()
#21 0x0000555555597470 in std::thread::_Invoker<std::tuple<void ()(CamInfo), CamInfo> >::operator()() ()
#22 0x0000555555596816 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void ()(CamInfo), CamInfo> > >::_M_run() ()
#23 0x00007ffff4b4b66f in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#24 0x00007ffff42c06db in start_thread (arg=0x7fffaaffd700) at pthread_create.c:463
#25 0x00007ffff3fe988f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
Backtrace with only
one device:
Thread 18 "RealSense" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe57f2700 (LWP 16887)]
0x00007fffcc006c00 in ?? ()
(gdb) bt
#0 0x00007fffcc006c00 in ?? ()
#1 0x000055555558dc50 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() ()
#2 0x00007ffff707d255 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::
__shared_count (this=0x7fffe57f15e8, __in_chrg=) at /usr/include/c++/7/bits/shared_ptr_base.h:684__shared_ptr (this=0x7fffe57f15e0, __in_chrg=) at /usr/include/c++/7/bits/shared_ptr_base.h:1123#3 std::__shared_ptr<librealsense::platform::time_service, (__gnu_cxx::_Lock_policy)2>::
#4 std::shared_ptrlibrealsense::platform::time_service::~shared_ptr (this=0x7fffe57f15e0, __in_chrg=) at /usr/include/c++/7/bits/shared_ptr.h:93
#5 librealsense::uvc_sensor::<lambda(librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void()>)>::operator()(librealsense::platform::frame_object, std::function<void()>) (__closure=0x555555a940f0, f=..., continuation=..., p=...) at /home/up/librealsense/src/sensor.cpp:449
#6 0x00007ffff707e627 in std::_Function_handler<void(librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void()>), librealsense::uvc_sensor::open(const stream_profiles&)::<lambda(librealsense::platform::stream_profile, librealsense::platform::frame_object, std::function<void()>)> >::_M_invoke(const std::_Any_data &, librealsense::platform::stream_profile &&, librealsense::platform::frame_object &&, std::function<void()> &&) (__functor=..., __args#0=..., __args#1=..., __args#2=...) at /usr/include/c++/7/bits/std_function.h:316
#7 0x00007ffff6fc39f5 in 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 (__args#2=..., __args#1=..., __args#0=..., this=0x55555590a400) at /usr/include/c++/7/bits/std_function.h:706
#8 librealsense::platform::v4l_uvc_device::poll (this=this@entry=0x55555590a2a0) at /home/up/librealsense/src/linux/backend-v4l2.cpp:884
#9 0x00007ffff6fc4148 in librealsense::platform::v4l_uvc_device::capture_loop (this=0x55555590a2a0) at /home/up/librealsense/src/linux/backend-v4l2.cpp:1225
#10 0x00007ffff4b4b66f in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#11 0x00007ffff42c06db in start_thread (arg=0x7fffe57f2700) at pthread_create.c:463
#12 0x00007ffff3fe988f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
My code:
#include // Terminal IO
#include // Stringstreams
#include
#include
#include
#include <condition_variable>
#include
#include
#include <librealsense2/rs.hpp> // RealSense Cross Platform API
#include <librealsense2/rsutil.h>
#include <opencv2/opencv.hpp> // OpenCV API
std::mutex mutex_id, mutex_sync, mutex_img_save;
std::condition_variable condition_sync, condition_img_save;
bool exit_cond = false;
bool start_cond = false;
int save_cnt = 0;
int id_inc = 0;
int waiting_thread_cnt = 0;
struct CamInfo {
rs2::pipeline pipe;
std::string serial;
};
struct FrameInfo {
CamInfo cam_info;
uint64_t img_idx;
};
void capture_thread(CamInfo cam_info);
void capture(FrameInfo frame_info);
void int_idx_to_str(uint64_t& img_idx,std::string& img_idx_str);
void intrinsics_to_csv(const rs2::pipeline_profile& profile, const std::string& filename);
int main(int argc, char * argv[]) try
{
// Create a context to manage devices
rs2::context ctx;
}
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;
}
void capture_thread(CamInfo cam_info)
{
int tid = 0;
mutex_id.lock();
tid = id_inc++;
mutex_id.unlock();
}
void capture(FrameInfo frame_info)
{
// Getting frame info
rs2::pipeline p = frame_info.cam_info.pipe;
std::string serial = frame_info.cam_info.serial;
uint64_t img_idx = frame_info.img_idx;
}
void int_idx_to_str(uint64_t& img_idx,std::string& img_idx_str)
{
std::stringstream ss;
if (img_idx < 100000) {
ss << 0;
if (img_idx < 10000) {
ss << 0;
if (img_idx < 1000) {
ss << 0;
if (img_idx < 100) {
ss << 0;
if (img_idx < 10) {
ss << 0;
}
}
}
}
}
ss << img_idx;
img_idx_str = ss.str();
}
void intrinsics_to_csv(const rs2::pipeline_profile& profile, const std::string& filename)
{
rs2::depth_sensor sensor = profile.get_device().firstrs2::depth_sensor();
rs2::video_stream_profile stream = profile.get_stream(RS2_STREAM_DEPTH).asrs2::video_stream_profile();
rs2_intrinsics intrinsics = stream.get_intrinsics();
rs2_distortion model = intrinsics.model;
}
The text was updated successfully, but these errors were encountered: