ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

What are possible reasons for ros::spinOnce causing segmentation faults?

asked 2012-08-18 00:36:27 -0500

Clefairy gravatar image

updated 2014-01-28 17:13:22 -0500

ngrennan gravatar image

I'm having a problem where ros::spinOnce() will cause my code to stop running because of a segmentation fault when it reaches that line. I'm not sure if it's possible to answer without seeing code but are there any general causes for this?

Thanks

edit retag flag offensive close merge delete

Comments

Could you post a stack trace from GDB? You can add launch-prefix="xterm -e gdb --args" to a node in your launchfile to make it come up in gdb.

jbohren gravatar image jbohren  ( 2012-08-18 01:09:41 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-08-18 06:33:29 -0500

Hi Clefairy,

Segmentation fault would occur only if there is an access to invalid memory. There could be several reasons for this to happen based on what you are doing in your code.

One simple scenario would be the case of a publisher and subscriber. If you are having both of these in your code, you are probably trying to access data from the subscriber which is not yet made ready by the publisher.

If you are using data structures like arrays there is a strong possibility of accessing data before making that ready.

Lastly, if you are running multiple spins you may have to set the same data rate throughout to avoid segmentation faults.

If you need further help we may be able to do that after seeing your code or the trace from gdb as pointed out by jbohren.

Regards,

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-08-18 00:36:27 -0500

Seen: 1,124 times

Last updated: Aug 18 '12