-
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
Segmentation Fault When Extracting Frames #885
Comments
All four cameras are run in separate Python3.6 interpreter sessions/processes. |
Whenever this error happens, it shows owner is a NULL pointer. (gdb) p owner I also have a backtrace which starts from the v4l2 backend: #0 0x00007fffccdc99f1 in librealsense::frame::release (this=0xffa680) at /home/arb/librealsense/src/archive.cpp:273 |
Hi @marvin-hao , Which version are you using? |
In master branch. The most recent log from my local git repo is: commit 5fb58db
|
I added NULL pointer checking for the member variable owner of realsense::frame in src/archive.cpp: void frame::release() and src/source.cpp: void frame_source::invoke_callback(frame_holder frame) const. It works well so far, but I'm not sure if this will cause potential memory leak or further hidden bugs. |
Can you please share a code snippet / sample that reproduces this issue so we can try it? |
Sorry, most of the confidential code interleaves within the camera control code, but I can share the control flow.
try {
self->pipe = rs2::pipeline();
if (!setup_streams(self))
return NULL;
self->pipe_profile = self->pipe.start(self->conf);
if (!setup_intrinsics(self))
return NULL;
self->dev = self->pipe_profile.get_device();
std::vector<rs2::sensor> sensors = self->dev.query_sensors();
// For SR300
if (sensors.size() != 2) {
PyErr_SetString(PyExc_RuntimeError, "...");
return NULL;
}
if (self->depth_sensor = sensors[0].as<rs2::depth_sensor>()){
self->depth_scale = self->depth_sensor.get_depth_scale();
} else {
PyErr_SetString(PyExc_RuntimeError, "...");
return NULL;
}
// RGB Camera
if (self -> roi_sensor = sensors[1].as<rs2::roi_sensor>()){}
else {
PyErr_SetString(PyExc_RuntimeError, "...");
return NULL;
}
} catch (rs2::error e) {
PyErr_SetString(PyExc_RuntimeError, e.what());
}
In an infinite loop: for (uint i = 0; i < maxFrames; ++i){
rs2::frameset frameset = pipe.wait_for_frames();
try {
auto color_frame = frameset.get_color_frame();
auto depth_frame = frameset.get_depth_frame();
auto ir_frame = frameset.first_or_default(RS2_STREAM_INFRARED);
// If come across bad frames, decrease the counter by 1 and continue.
if (
!ir_frame || ir_frame.get_data() == NULL ||
!color_frame || color_frame.get_data() == NULL ||
!depth_frame || depth_frame.get_data() == NULL) {
--i;
continue;
}
CompFrame memData = {
(uint8_t *)(color_frame.get_data()),
(uint16_t *)(depth_frame.get_data()),
(uint8_t *)(ir_frame.get_data())
};
... (calculation that uses intrinsic and extrinsic)
} catch (std::exception &e) {
throw e;
}
} We found after we patched the source files I commented before, there's no more segmentation fault. My concern is that if simply skipping null owner will cause a memory leak or other bugs. |
Hi @marvin-hao |
we do use some C APIs like rs2_deproject_pixel_to_point to align frames. Is there any available C++ API exposed already? We did use C++ API to align in rs1. |
There is no limitation to mix C and C++ APIs, however, my concern is that the function |
@marvin-hao please open-new issue if you reproduce this problem (closing for now) |
I also run into Could you please show your solution? Although you have shared your I am puzzled by this problem for several days, my detailed situation is here. Could you provide your solution? Thanks in advance. |
I ran 4 SR300 cameras on one computer and utilized color, depth and ir streams at full resolution. After a while, I came across the following error (can replicate but not deterministic):
Thread 1 "python3.6" received signal SIGSEGV, Segmentation fault.
0x00007fffccdc99f1 in librealsense::frame::release (this=0xfd3558) at /home/arb/librealsense/src/archive.cpp:273
273 owner->unpublish_frame(this);
Backtrace:
#0 0x00007fffccdc99f1 in librealsense::frame::release (this=0xfd3558) at /home/arb/librealsense/src/archive.cpp:273
No locals.
#1 0x00007fffccf1fe6e in rs2_release_frame (frame=0xfd3558) at /home/arb/librealsense/src/rs.cpp:813
FUNCTION = "rs2_release_frame"
PRETTY_FUNCTION = "void rs2_release_frame(rs2_frame*)"
#2 0x00007fffcd7275ee in rs2::frame::~frame (this=, __in_chrg=) at /usr/local/include/librealsense2/hpp/rs_frame.hpp:172
No locals.
#3 rs2::frameset::foreach<rs2::frameset::first_or_default(rs2_stream) const::{lambda(rs2::frame)#1}>(rs2::frameset::first_or_default(rs2_stream) const::{lambda(rs2::frame)#1}) const (action=..., this=) at /usr/local/include/librealsense2/hpp/rs_frame.hpp:523
fref = 0xfd3558
i = 1
e = 0x0
#4 rs2::frameset::first_or_default (s=RS2_STREAM_COLOR, this=) at /usr/local/include/librealsense2/hpp/rs_frame.hpp:479
No locals.
#5 rs2::frameset::get_color_frame (this=) at /usr/local/include/librealsense2/hpp/rs_frame.hpp:498
f = {frame_ref = 0x0}
The library is compiled from source. Realsense Viewer works well.
Here is the source code:
for (...){
rs2::frameset frameset = pipe.wait_for_frames();
The text was updated successfully, but these errors were encountered: