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

How to debug rmw segfaults launched by ros2cli like `ros2 topic echo`?

asked 2021-08-15 02:25:29 -0500

zhensheng gravatar image

updated 2021-08-21 15:33:35 -0500

I am a developer of rmw_iceoryx, I ran into problems about segfault when executing ros2cli like ros2 topic echo /topic, bug I cannot find a way to debug this kind of problem, see this issue if you like.

I know it is about python and cpp debug and I tried using vscode python debug launcher to debug ros2cli python script, but failed to catch the segment exception.

So, does anybody has experence on debug ros2cli code that dynamiclly load rmw interface?

Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2021-08-21 11:43:03 -0500

updated 2021-08-21 11:45:04 -0500

I found this: https://wiki.python.org/moin/Debuggin...

I installed the Python debug package (Ubuntu 20.04):

$ sudo apt-get install python3-dbg

If you try to blindly follow the examples, it doesn't work if you just do:

$ gdb -ex r --args ros2 topic /echo
"/home/$USER/ros2_ws/install/ros2cli/bin/ros2": not in executable format: file format not recognized

So you have to run python3 with the actual entrypoint Python file (which you can see in the error message) as the first argument + the rest. You can also use which to find the Python file corresponding to ros2:

$ gdb -ex r --args python3 `which ros2` topic echo /topic

This seemed to run gdb correctly for me, but with the default RMW implementation there's no segfault, so I can't tell if it actually gives a stack trace, etc. It should, though, according to what I can see in the link above. Let us know if it works!

edit flag offensive delete link more

Comments

Works like a charm, thanks for the hint!

moss gravatar image moss  ( 2022-01-04 12:22:44 -0500 )edit
1

answered 2022-01-13 06:21:52 -0500

zhensheng gravatar image

your method works on vscode too. Thank you very much!

the launch file in vscode is like

json { "name": "zs: gdbrun ros2", "type": "cppdbg", "request": "launch", "program": "/usr/bin/python3", "args": [ "/opt/ros/foxy/bin/ros2", "topic", "echo", "/tf_static" ], "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [ { "name": "RMW_IMPLEMENTATION", // "value": "rmw_fastrtps_cpp" // "value": "rmw_ecal_proto_cpp" "value": "rmw_iceoryx_cpp" } ], "externalConsole": false, // "preLaunchTask": "source_ros2_ws", "MIMode": "gdb", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] },

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2021-08-15 02:25:29 -0500

Seen: 725 times

Last updated: Jan 13 '22