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

Is there functionality built into ros to get nodes to print a stacktrace on crash?

asked 2011-05-11 16:28:02 -0500

updated 2012-02-27 13:31:11 -0500

kwc gravatar image

When ROS nodes crash, modifying launch files to run under gdb is often required to get a stack trace. And a full reattempt to produce the conditions of the crash is necessary.

75% of crash failures (made up number :) could probably be solved without running in the debugger if we could see where the crash happened on each failure.

Is there functionality built into ROS to handle this?

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2011-05-11 16:42:30 -0500

updated 2011-05-12 05:52:24 -0500

One option (which has nothing to do with ROS internals) is to set the ulimit on core file to be non-zero and then analyze the core after the crash. (By default the core size limit is set to 0 in Ubuntu)

Set to unlimited:

ulimit -c unlimited

This will cause the OS to produce a "core file" each time there is a crash which contains some of the info needed to recreate a stack trace. The other portion of the info is contained in the executable which crashed.

The core file ends up in ~/.ros and can be analyzed with gdb like so:

gdb --core=~/.ros/core  /path/to/stack/package/bin/mynode

... where a backtrace can be obtained by using the "backtrace" or "bt" command

edit flag offensive delete link more



Has anyone had any luck doing this? The core file doesn't seem to turn up in ~/.ros for me...

dg-shadow gravatar image dg-shadow  ( 2017-05-23 11:22:26 -0500 )edit

Had the same problem as you, ROS kinetic on Ubuntu 16.04. Tried the /proc/sys... stuff here as well:

alf gravatar image alf  ( 2017-10-04 06:38:44 -0500 )edit

I was able to follow this, my core dump was in /var/crash, and you can find the executable of a package folder using pkgname=<your package name>

catkin_find --first-only --without-underlays --libexec ${pkgname}

then after starting gdb with the top command, you can type bt, or where

Beshari gravatar image Beshari  ( 2022-08-25 18:41:03 -0500 )edit

answered 2011-05-12 04:43:30 -0500

Straszheim gravatar image

There is not. You could ticket this as an enhancement...

edit flag offensive delete link more

answered 2011-05-12 05:17:39 -0500

dornhege gravatar image

I think it is not necessary, when you build in debug mode. As you already said, you can just use a debugger to get the stacktrace information from the core.

Besides that, there is ROS_ASSERT, but that does only work on the crashes you somehow could predict.

edit flag offensive delete link more

Question Tools



Asked: 2011-05-11 16:28:02 -0500

Seen: 2,422 times

Last updated: May 12 '11