segfault in spinOnce, what is wrong?

asked 2017-11-03 11:12:45 -0600

knxa gravatar image

updated 2017-11-03 14:48:12 -0600

I have nodes crashing short after launch, the console output is for example:

[JoggingNode-21] process has died [pid 29521, exit code -11

The problem only appears when I start the full system with 30+ nodes, not if I launch the single node.

The problem appears for different nodes for each launch.

The problem seems to be highly timing dependent and disappears if I launch the node with gdb or relaunch the crashed node while leaving the other nodes running.

I can printf debug the problem down to calling spinOnce.

Questions:

  1. What is exit code -11 ?
  2. Any way I can see in a log which callbacks ROS has been calling
  3. Is combining spin and spinOnce a problem? I use it through out several nodes like shown below:

ROS node pseudo code:

void someCallback() {
    while (!ready) {
        spin_once();
    }
    ...
}
void someCallback2() {
     ready = true;
}

int main() {
    ...
    setupCallbacks();
    spin();
}

[EDIT]

Edited title. Also managed to get a core dump, here is the stack trace:

(gdb) bt
#0  0x00007fd568a88fac in std::deque<ros::CallbackQueue::CallbackInfo, std::allocator<ros::CallbackQueue::CallbackInfo> >::_M_erase(std::_Deque_iterator<ros::CallbackQueue::CallbackInfo, ros::CallbackQueue::CallbackInfo&, ros::CallbackQueue::CallbackInfo*>) () from /opt/ros/kinetic/lib/libroscpp.so
#1  0x00007fd568a85cc1 in ros::CallbackQueue::callOneCB(ros::CallbackQueue::TLS*) ()
   from /opt/ros/kinetic/lib/libroscpp.so
#2  0x00007fd568a870f3 in ros::CallbackQueue::callAvailable(ros::WallDuration) ()
   from /opt/ros/kinetic/lib/libroscpp.so
#3  0x00007fd568ac4795 in ros::spinOnce() () from /opt/ros/kinetic/lib/libroscpp.so
edit retag flag offensive close merge delete

Comments

Comments to see whether others answer:

  1. -11 is SEGFAULT
  2. no, not without instrumenting code yourself
  3. I would not recommend doing what you are doing at all. Perhaps if you can tell us what you're trying to achieve there we can suggest some other way to do this.
gvdhoorn gravatar image gvdhoorn  ( 2017-11-03 11:52:44 -0600 )edit

Oh I would love some advice on the spin design. I feel this is appropriate for a new question

knxa gravatar image knxa  ( 2017-11-03 13:10:11 -0600 )edit

Thanks for trying to get that GDB backtrace, but without debug symbols it's not going to be very informative.

gvdhoorn gravatar image gvdhoorn  ( 2017-11-04 06:14:16 -0600 )edit

Well, my intention was just to verify that the crash is in the spinOnce code itself, not in my callback code.

knxa gravatar image knxa  ( 2017-11-04 11:35:31 -0600 )edit