Skip to content
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

float comparison in BaseNodelet::publishPCTopic() causes out of bound access and segmentation fault #335

Closed
lsolanka opened this issue Mar 5, 2018 · 1 comment
Labels

Comments

@lsolanka
Copy link

lsolanka commented Mar 5, 2018

With my R200, for some reason this code:

 if (color_pixel[1] < 0.0f || color_pixel[1] > image_color.rows
     || color_pixel[0] < 0.0f || color_pixel[0] > image_color.cols)
{
   // For out of bounds color data, default to a shade of blue in order to visually distinguish holes.
   // This color value is same as the librealsense out of bounds color value.
   *iter_r = static_cast<uint8_t>(96);
   *iter_g = static_cast<uint8_t>(157);
   *iter_b = static_cast<uint8_t>(198);
}
else
{
  int i = static_cast<int>(color_pixel[0]);
  int j = static_cast<int>(color_pixel[1]);

  *iter_r = static_cast<uint8_t>(color_data[i * 3 + j * image_color.cols * 3]);
  *iter_g = static_cast<uint8_t>(color_data[i * 3 + j * image_color.cols * 3 + 1]);
  *iter_b = static_cast<uint8_t>(color_data[i * 3 + j * image_color.cols * 3 + 2]);
}

Causes a segmentation fault because from time to time color_pixel[1] == image_color.rows or color_pixel[0] == image_color.cols.

The image access in the else clause is then out of bounds by 1 pixel, and librealsense_camera_nodelet.so segfaults as a result.

@lsolanka
Copy link
Author

lsolanka commented Apr 7, 2018

Hi,
I noticed that you closed this issue without merging the pull request. Is there any issue with the patch? Is it not relevant?

doronhi added a commit to doronhi/realsense that referenced this issue Jul 17, 2018
doronhi added a commit to doronhi/realsense that referenced this issue Jul 17, 2018
doronhi added a commit that referenced this issue Aug 9, 2018
* fix issue #335 according to solution lsolanka as suggested in pull request #336.

* moving all the properties and material definitions inside the macro as suggested by @felixvd

* add compilation flag SET_USER_BREAK_AT_STARTUP to create user waiting point for debugging purposes.

add reading from bagfile option by using <rosbag_filename> parameter in launch file.
base_realsense_node.cpp: add option - by specifying width, height or fps as 0, pick up on the first sensor profile available.
scripts/rs2_listener.py, rs2_test.py - initial version for file based, standalone unitest.

* add .travis.yml file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants