introlab / rtabmap_ros

RTAB-Map's ROS package.
http://wiki.ros.org/rtabmap_ros
BSD 3-Clause "New" or "Revised" License
967 stars 557 forks source link

Debugging "process has died" errors on startup or segmentation fault #28

Open matlabbe opened 9 years ago

matlabbe commented 9 years ago

This post is about ROS1. For ROS2, see this post below https://github.com/introlab/rtabmap_ros/issues/28#issuecomment-1336292967

A : Launch in GDB

Before continuing, make sure xterm and gdb are installed:

$ sudo apt-get install xterm gdb

Before rebuilding source or in Debug mode (B,C), launch the crashing node in gdb.

If you are using rtabmap.launch:

roslaunch rtabmap_ros rtabmap.launch launch_prefix:="xterm -e gdb -ex run --args"

If using rtabmap or rgbd_odometry nodes directly in your launch file, we can add the launch-prefix like that:

   <node pkg="rtabmap_ros" type="rgbd_odometry" name="rgbd_odometry" launch-prefix="xterm -e gdb -ex run --args">
   ...
   </node>
   <node pkg="rtabmap_ros" type="rtabmap" name="rtabmap" launch-prefix="xterm -e gdb -ex run --args">
   ...
   </node>

When the node crashes, type bt (backtrace). If the log contains Eigen stuff, see this comment about -march=native compilation flag problem.

B : Build from source

If you are using the binaries (e.g., ros-indigo-rtabmap and ros-indigo-rtabmap-ros):

  1. Uninstall them:

    $ sudo apt-get remove ros-indigo-rtabmap ros-indigo-rtabmap-ros
  2. Install rtabmap and rtabmap_ros from source following this instructions.
  3. Launch rgbd_mapping.launch

    $ roslaunch rtabmap_ros rgbd_mapping.launch

If the nodes are still crashing, go to B.

C : Build in Debug mode

If A doesn't work, clean up your catkin workspace and build rtabmap in Debug mode:

  1. Remove the binaries:

    $ sudo apt-get remove ros-indigo-rtabmap ros-indigo-rtabmap-ros
  2. Clean your catkin workspace (assuming your catkin workspace is ~/catkin_ws, just keep src folder):

    $ cd ~/catkin_ws
    $ rm -r build devel install
  3. Build rtabmap in debug mode (should not be cloned in catkin workspace):

    $ cd ~
    $ git clone https://github.com/introlab/rtabmap.git rtabmap
    $ cd rtabmap/build
    $ cmake -DCMAKE_INSTALL_PREFIX=~/catkin_ws/devel -DCMAKE_BUILD_TYPE=Debug .. 
    $ make -j4
    $ make install
  4. Build rtabmap_ros in debug mode:

    $ cd ~/catkin_ws
    $ git clone https://github.com/introlab/rtabmap_ros.git src/rtabmap_ros
    $ catkin_make -DCMAKE_BUILD_TYPE=Debug
  5. Source your setup.bash

    $ source ~/catkin_ws/devel/setup.bash
  6. Launch rgbd_mapping.launch

    $ roslaunch rtabmap_ros rgbd_mapping.launch
  7. Now, if rtabmap is still crashing, start the launch file with gdb to track down where it is crashing (make sure you have the latest version of rgbd_mapping.launch with launch_prefix argument):

    $ roslaunch rtabmap_ros rgbd_mapping.launch launch_prefix:="xterm -e gdb -ex run --args"

    When an error comes up, you can use backtrace (or simply bt) command in gdb to show more info.

  8. Open an issue here with the log of gdb for the nodes crashing and with which kind of computer you are using.
mhk4zemi commented 9 years ago

i follow this tutorial and get a log file:

can not access memory at address 0x0
matlabbe commented 9 years ago

Do every nodes (rtabmap, rgbd_odometry, rtabmapviz) produce this error? Is there a line where it crashes in the code? Can you show the full log for each node?

A fast search on Google for this error and this what I've found so far. It seems related to some modifications of the argc and argv variables (memory stack of the application corrupted). It seems happening on 32 bits architecture and on specific gcc version. Are you 32bits or 64bits? Which gcc version do you have (gcc --version)?

gabrielarpino commented 8 years ago

I did all of step A, but get this error:

[rgbd_mapping.launch] is neither a launch file in package [rtabmap_ros] nor is [rtabmap_ros] a launch file name The traceback for the exception was written to the log file

matlabbe commented 8 years ago

Make sure you source the setup.bash in your catkin_ws/devel folder: http://answers.ros.org/question/143496/roslaunch-is-neither-a-launch-file-in-package-nor-is-a-launch-file-name/

KamalDSOberoi commented 8 years ago

What if the node doesn't crash on startup but crashes after some time on ROS Indigo?

willdzeng commented 8 years ago

@KamalDSOberoi What is the crash error?

KamalDSOberoi commented 8 years ago

@willdzeng There is no error. It just says that the process has died. In my case map_optimizer crashes/dies frequently but not on startup. It executes for sometime and then it dies.

gabrielarpino commented 8 years ago

Fixed it by sourcing the setup file in the catkin_ws. Thanks!

matlabbe commented 8 years ago

@KamalDSOberoi Are you using a modified version of map_optimizer node?

KamalDSOberoi commented 8 years ago

@matlabbe I think no. Did you make significant changes?

matlabbe commented 8 years ago

I just made a simple test launch file test_map_optimizer.launch for map_optimizer node. I cannot reproduce the crash. This error can appear on start though when the camera stands still:

[ERROR] [1470151850.812122935]: map_optimizer: Poses=2 and edges=0 (poses must not be null if there are edges, and edges must be null if poses <= 1)

But disappear when the camera starts moving.

matlabbe commented 1 year ago

ROS2 + GDB

sudo apt-get install xterm gdb
ros2 launch rtabmap_ros rtabmap.launch.py \
   rtabmap_args:="-d --udebug" \
   launch_prefix:="xterm -e gdb -ex run --args"

Or if you use a Node configuration in your launch file:


Node(
  package='rtabmap_ros', executable='rtabmap', output="screen",
  arguments="-d --udebug",
  prefix="xterm -e gdb -ex run --args",
  ...
)