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

Segfault for rosrun gpd_ros detect_grasps_server #6

Open
aPonza opened this issue Oct 11, 2019 · 0 comments · May be fixed by #7
Open

Segfault for rosrun gpd_ros detect_grasps_server #6

aPonza opened this issue Oct 11, 2019 · 0 comments · May be fixed by #7

Comments

@aPonza
Copy link

aPonza commented Oct 11, 2019

Initiating the command rosrun gpd_ros detect_grasps_server results in a SIGSEGV with backtrace:

(gdb) bt
#0  0x000000000040e30c in GraspDetectionServer::GraspDetectionServer (this=0xffeffee70, node=...)
    at ~/catkin_ws/src/gpd2_ros/src/gpd_ros/grasp_detection_server.cpp:14
#1  0x000000000040d71e in main (argc=1, argv=<optimized out>)
    at ~/catkin_ws/src/gpd2_ros/src/gpd_ros/grasp_detection_server.cpp:132

and valgrind is saying:

==20809== Invalid read of size 8
==20809==    at 0x40E30C: GraspDetectionServer::GraspDetectionServer(ros::NodeHandle&) (grasp_detection_server.cpp:14)
==20809==    by 0x40D71D: main (grasp_detection_server.cpp:132)
==20809==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

It didn't make much sense (the error was alternating between the std::string constructor and the ros::NodeHandle object) and the culprit is unrelated to the error messages:

https://github.com/atenpas/gpd2_ros/blob/63cec397d5c2ee064f32d21afe373290da5b63fa/src/gpd_ros/grasp_detection_server.cpp#L11

Commenting this line, and it's declaration in https://github.com/atenpas/gpd2_ros/blob/master/include/gpd_ros/grasp_detection_server.h#L103 results in no more segfaults. The variable is uninitialized (and never used anyways) so either a simple

diff --git a/src/gpd_ros/grasp_detection_server.cpp b/src/gpd_ros/grasp_detection_server.cpp
index 171b6d9..94d7e2f 100644
--- a/src/gpd_ros/grasp_detection_server.cpp
+++ b/src/gpd_ros/grasp_detection_server.cpp
@@ -6,7 +6,7 @@ GraspDetectionServer::GraspDetectionServer(ros::NodeHandle& node)
   cloud_camera_ = NULL;
 
   // set camera viewpoint to default origin
-  std::vector<double> camera_position;
+  auto camera_position = std::vector<double> {0.0, 0.0, 0.0};
   node.getParam("camera_position", camera_position);
   view_point_ << camera_position[0], camera_position[1], camera_position[2];

or deleting the variable, work.

aPonza pushed a commit to aPonza/gpd2_ros that referenced this issue Oct 11, 2019
@aPonza aPonza linked a pull request Oct 11, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant