GDB backtrace does not work correctly for Thumb-2 on armel

Bug #523959 reported by Dave Martin
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Linaro GDB
Fix Released
Medium
Ulrich Weigand
gdb (Ubuntu)
Fix Released
Medium
Steve Langasek

Bug Description

Binary package hint: gdb

Observed in a native gdb trunk build on 20100217 (built and run on Ubuntu lucid)
Observed in Ubuntu gdb 7.0.1-0ubuntu1 (Ubuntu lucid)

GDB generally identifies at most 2 or 3 frames of backtrace and then gives up (or occasionally,
gets into an infinite loop).

The following log shows an example of the kind of behaviour I see.

In a separate case, debuuging a now fixed problem in objdump, gdb fails to notice the identical
stack frame and gets into an infinite loop.

Similar results are seen regardless of whether debugging info is available.

~# gdb /usr/sbin/rsyslogd-
GNU gdb (GDB) 7.0.50.20100218-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "armv7l-unknown-linux-gnueabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /usr/sbin/rsyslogd-...(no debugging symbols found)...done.
(gdb) set follow-fork-mode child
(gdb) r
Starting program: /usr/sbin/rsyslogd-
[Thread debugging using libthread_db enabled]
[New process 11139]
[Thread debugging using libthread_db enabled]
[New Thread 0x40a19470 (LWP 11140)]
[New Thread 0x41219470 (LWP 11141)]
[New Thread 0x41a19470 (LWP 11142)]
[New Thread 0x42219470 (LWP 11143)]
^C
Program received signal SIGINT, Interrupt.
[Switching to Thread 0x400191c0 (LWP 11139)]
0x4011cb30 in select () from /lib/libc.so.6
(gdb) bt
#0 0x4011cb30 in select () from /lib/libc.so.6
#1 0x4012b966 in ?? () from /lib/libc.so.6
#2 0x4012b966 in ?? () from /lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb) q
A debugging session is active.

 Inferior 2 [process 11139] will be killed.

Quit anyway? (y or n) y
~#

Related branches

Revision history for this message
Dave Martin (dave-martin-arm) wrote :
Loïc Minier (lool)
tags: added: armv7 thumb
Revision history for this message
Loïc Minier (lool) wrote :

Ulrich, I saw "gdb" and I thought of you! ;-) Would you be tempted to try reproducing this issue with gdb tip, and if it's still an issue, to work on a fix? :-)

Revision history for this message
Ulrich Weigand (uweigand) wrote :
Download full text (3.7 KiB)

I was unable to investigate much in the original reported scenario, because the libc.so binary is missing from the tarball:

uweigand@beagle:~$ tar tfz t2-bt-testcase.tar.gz
usr/sbin/rsyslogd-
lib/libz.so.1
lib/libpthread.so.0
lib/libdl.so.2
lib/librt.so.1
lib/libgcc_s.so.1
lib/libc.so.6
usr/lib/debug/usr/sbin/rsyslogd
usr/lib/debug/lib/libpthread-2.11.1.so
usr/lib/debug/lib/libdl-2.11.1.so
usr/lib/debug/lib/librt-2.11.1.so
usr/lib/debug/lib/libc-2.11.1.so

Note that lib/libc.so.6, which is just a symbolic link, is there, but lib/libc-2.11.1.so, which is where the link goes to, is missing.

Nevertheless, I was able to reproduce similar problems when attempting to backtrace out of interrupted system calls. For example, I've been using the following example:

#include <unistd.h>

int main (void)
{
  sleep (1000);
}

Running this in GDB 7.2 and interrupting results in:

uweigand@beagle:~$ ./gdb-7_2-build/gdb/gdb ./a.out
GNU gdb (GDB) 7.1.90.20100709-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "armv7l-unknown-linux-gnueabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/uweigand/a.out...done.
(gdb) run
Starting program: /home/uweigand/a.out
^C
Program received signal SIGINT, Interrupt.
0x4008e02c in nanosleep () from /lib/libc.so.6
(gdb) bt
#0 0x4008e02c in nanosleep () from /lib/libc.so.6
#1 0x4008de70 in sleep () from /lib/libc.so.6
#2 0x4008de70 in sleep () from /lib/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
(gdb)

However, when I install the libc6-dbg debuginfo package, backtraces work:

uweigand@beagle:~$ ./gdb-7_2-build/gdb/gdb ./a.out
GNU gdb (GDB) 7.1.90.20100709-cvs
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "armv7l-unknown-linux-gnueabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/uweigand/a.out...done.
(gdb) run
Starting program: /home/uweigand/a.out
^C
Program received signal SIGINT, Interrupt.
0x4008e02c in nanosleep () at ../sysdeps/unix/syscall-template.S:82
82 ../sysdeps/unix/syscall-template.S: No such file or directory.
        in ../sysdeps/unix/syscall-template.S
(gdb) bt
#0 0x4008e02c in nanosleep () at ../sysdeps/unix/syscall-template.S:82
#1 0x4008de70 in __sleep (seconds=0) at ../sysdeps/unix/sysv/linux/sleep.c:138
#2 0x000083c0 in main () at t.c:6
(gdb)

The reason why backtraces do not work without debug info is that GDB will fall back to analyzing function prologue code instead. This requires GDB to understand and decode all instructions that may be used in such ...

Read more...

Revision history for this message
Ulrich Weigand (uweigand) wrote :

I've now committed a patch to mainline GDB that significantly improves backtraces for Thumb-2 code even in the absence of DWARF CFI debug info. This will still not handle absolutely all cases (e.g. hand-written assembler routines that don't follow usual conventions), but should still help quite a bit:
http://sourceware.org/ml/gdb-patches/2010-10/msg00132.html

Changed in gdb-linaro:
importance: Undecided → Medium
status: New → In Progress
Changed in gdb-linaro:
assignee: nobody → Ulrich Weigand (uweigand)
Changed in gdb-linaro:
status: In Progress → Fix Committed
milestone: none → 7.2-2010.10-0
Michael Hope (michaelh1)
Changed in gdb-linaro:
status: Fix Committed → Fix Released
Steve Langasek (vorlon)
tags: added: arm-porting-queue
Changed in gdb (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
assignee: nobody → Steve Langasek (vorlon)
Revision history for this message
Steve Langasek (vorlon) wrote :

Sorry, this one seems to have fallen through the cracks on the package side. If this was fixed upstream in 2010-10, can we assume that the fix is present in the 7.4-0ubuntu1 package in precise?

Revision history for this message
Ulrich Weigand (uweigand) wrote :

Yes, the fix is present in GDB 7.4 (and in fact already GDB 7.3) release.

Steve Langasek (vorlon)
Changed in gdb (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.