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

Why isn't gdb working for me

asked 2017-02-14 17:05:07 -0500

sharan100 gravatar image

updated 2017-02-17 05:23:35 -0500


I am currently trying to build an autonomous drone using ROS on my Rapsberry Pi which is running an Ubuntu MATE 16.04 LTS. Solving the Computer Vision problem of recognising red circles as of now.

Specific Problem

I am constantly getting the error I get in this question. To help me solve this, I have decided to use gdb. However, the command rosrun --prefix 'gdb run --args' zlab_drone vdstab does not seem to be working for me. zlab_drone is the name of the package and vdstab is the name of the executable I am trying to run. Since this is inside a ROS environment, I have grabbed the syntax from here, and used the suggestions in #q222530.

When I invoke this command, even with tui, I get a SIGSEGV and when I invoke list inside gdb itself, the program does not stay at a particular point and keeps listing a different line till it is out of range. This is quite a weird issue.

I managed to make it work without this issue earlier by using a different command, I reckon. I just cannot remember how I made it work last time.


So, I try to run my program with the command:

rosrun --prefix 'gdb run --args' zlab_drone vdstab

and I get:

GNU gdb (Ubuntu 7.11-0ubuntu1) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/sharan/catkin_ws/devel/lib/zlab_drone/vdstab...done.

Which is all okay till now. Now I run start, at which point I get:

(gdb) start 
Temporary breakpoint 1 at 0x1e436: file /home/sharan/catkin_ws/src/zlab_drone/src/vidStab.cpp, line 136.
Starting program: /home/sharan/catkin_ws/devel/lib/zlab_drone/vdstab 

Program received signal SIGSEGV, Segmentation fault.
0x76fd9822 in ?? () from /lib/

Which is a bit weird. To see where the segmentation fault is, I try to list. The first time I get this:

(gdb) list 
122 //  warpAffine(cv_ptr->image, orig_warped, invTrans.rowRange(0,2), 
123 //          Size());
125     // Publishing (Only uncomment, if you're sure nothing is broken
126     // in this section)
127     /*
128     cv_ptr->image = orig_warped; 
129     image_pub_.publish(cv_ptr->toImageMsg());   
130     */
131     }

The second time, I get this:

(gdb) list 
133 };
135 int main(int argc, char** argv)
136 {
137   ros::init(argc, argv, "video_stabilizer");
138   Tracker tr;
139   ros::spin();
140   return 0;
141 }


142 ...
edit retag flag offensive close merge delete


Seems like your terminal state might be funky. Try running stty sane to reset it before you start your node.

ahendrix gravatar image ahendrix  ( 2017-02-15 02:58:30 -0500 )edit

@ahendrix nope, invoked stty sane and restarted the program but I still get the error:

Program received signal SIGSEGV, Segmentation fault.
0x76fd9822 in ?? () from /lib/

I even restarted the Raspberry Pi.

sharan100 gravatar image sharan100  ( 2017-02-15 03:34:29 -0500 )edit

I don't think @ahendrix' comment was meant as a solution to your SEGFAULT, but it could've been a way to get gdb to behave again.

gvdhoorn gravatar image gvdhoorn  ( 2017-02-15 05:54:50 -0500 )edit

@gvdhoorn Yeah, I got that, but I was just expanding on the fault that I am getting

sharan100 gravatar image sharan100  ( 2017-02-15 06:51:52 -0500 )edit

To clarify: running stty sane should fix the issue where running list in gdb produces unending output, but it won't fix your segfault. The segfault is almost certainly a bug in your code.

ahendrix gravatar image ahendrix  ( 2017-02-15 13:15:31 -0500 )edit

Yes of course, I get that. But it is obviously buggy, as it should manually go to the start of main and then approach the segfault through step or next.

sharan100 gravatar image sharan100  ( 2017-02-15 13:34:14 -0500 )edit

It sounds like you're expecting things from gdb that it doesn't do by default. Can you edit your question to include the full text of your debugging session?

ahendrix gravatar image ahendrix  ( 2017-02-15 14:07:27 -0500 )edit

yeah, I've posted exactly what I get when I open up gdb. The thing is, I didn't get this, last time I ran gdb, where I used specific syntax.

sharan100 gravatar image sharan100  ( 2017-02-16 04:11:13 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-02-16 15:03:43 -0500

ahendrix gravatar image

It looks like your program is crashing on startup. There is code that runs before main, and it looks like something in there is crashing.

gdb's list command is not my preferred choice for debugging; looking at the backtrace (gdb's backtrace command) will show the series of function calls and the final line where your program crashed.

edit flag offensive delete link more


I have just added what happens when I use backtrace instead of list.

sharan100 gravatar image sharan100  ( 2017-02-17 05:23:59 -0500 )edit

This looks a lot like ; which suggests that you can get around the issue by connecting gdb to your process after it starts:

ahendrix gravatar image ahendrix  ( 2017-02-17 12:28:59 -0500 )edit

yeah that workaround is the solution to this, it seems like. Either ways, for convenience's sake, I shall use valgrind.

sharan100 gravatar image sharan100  ( 2017-02-17 14:17:37 -0500 )edit

okay, it seems like I get a similar error with valgrind. Should I take this up somewhere?

sharan100 gravatar image sharan100  ( 2017-02-17 14:24:31 -0500 )edit

It seems like this is a bug in gdb or Ubuntu's version of gdb, so I recommend that you follow up on the launchpad bug that I linked to.

ahendrix gravatar image ahendrix  ( 2017-02-18 17:20:51 -0500 )edit

Question Tools

1 follower


Asked: 2017-02-14 17:05:07 -0500

Seen: 1,123 times

Last updated: Feb 17 '17