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

GazeboRos constructor causes segfault #478

Closed
canalteks opened this issue Jul 27, 2016 · 6 comments
Closed

GazeboRos constructor causes segfault #478

canalteks opened this issue Jul 27, 2016 · 6 comments

Comments

@canalteks
Copy link

Dear developers,

I found that GazeboRos constructor for Sensor in "gazebo_ros_utils.h" causes segfault.
It's because that the member variable "rosnode_" was not initialized before using it.

  • in GazeboRos( sensors::SensorPtr _parent, ... ) constructor.
  • that calls "GazeboRos::readCommonParameter()".
  • the member function uses "rosnode_" variable to initialize "tf_prefix_" variable.
  • but the "rosnode_" variable was not initialized in the GazeboRos( sensors ... ) constructor.

I hope, it could be helpful.

@j-rivero
Copy link
Contributor

j-rivero commented Aug 4, 2016

Thanks for the report. Could you please attach an example code that triggers the segfault?

@canalteks
Copy link
Author

Thanks for your reply.

It could easily regenerate segfault just to call "GazeboROS( sensors::SensorPtr, ... )".

Following code might be help.

class plugin_t : public gazebo::SensorPlugin
{
 void Load( gazebo::sensors::SensorPtr s, sdf::ElementPtr e );
 ...
}

void plugin_t::Load( gazebo::Sensors::SensorPtr s, sdf::ElementPtr  e )
{
 ...
 GazeboRos*  gaz_ros = new GazeboRos(s,e,"plugin_name");
 ...
}

To avoid the segfault, I've inserted the code before at line 171 in gazebo_ros_util.h.

 rosnode_ = boost::shared_ptr<ros::NodeHandle>( new ros::NodeHandle(namespace_));

Please see my previous comment, the reason why the segfault has occurred.

My environment is

  • Debian jessie
  • ROS kinetic

@jonbinney
Copy link
Contributor

This definitely looks like a bug. Looks like one of the constructors for the GazeboRos initializes the node handle, but the other doesn't. I've seen periodic segfaults in gazebo when using with ROS, but if this is the cause I'm not sure why it doesn't happen every time.

@scpeters
Copy link
Member

scpeters commented May 24, 2018

Fixed in melodic by #718, but we should backport to lunar and kinetic too, and indigo

@canalteks
Copy link
Author

@scpeters
I appliciate your efforts. Thank you.

@j-rivero
Copy link
Contributor

Fix committed and propagated to all branches. Thanks everyone for the efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants