backtrace/1547: corrupt stack?

Francois Taiani
Thu Oct 27 13:08:00 GMT 2005

The following reply was made to PR backtrace/1547; it has been noted by GNATS.

From: Francois Taiani <>
Subject: Re: backtrace/1547: corrupt stack?
Date: Thu, 27 Oct 2005 14:03:08 +0100

 Dear GDB team,
 This problems looks similar to the one reported by Andrew de Quincey 
 here [1] (copied below). Andrew provides a far smaller and 
 easy-to-repeat example:
 Basically gdb seems to struggle to analyse stack frames from code 
 compiled with the options "-O2 -fPIC". If you happen to debug a program 
 that uses optimised libraries, you tipically run into this kind of 
 problems, even if your program does not use those options.
 For information, the problem does not seem to be limited to PPC405 code. 
 I've got the same issue on my G4 powerbook (with gdb 2.3, gcc 4.0.2, and 
 a 2.6x kernel), it has been reported to happen on x86 as well. See [2]:
 Older versions of gdb do not seem to suffer from this. It might be 
 related to the use of newer gcc versions as well.
 From: Andrew de Quincey <adq_dvb at lidskialf dot net>
 To: gdb at sources dot redhat dot com
 Date: Mon, 8 Nov 2004 00:19:19 +0000
 Subject: GDB, g++, backtrace problem
 Hi, I've now patched my PPC405 kernel so GDB's breakpoints work 
 correctly. I now have another problem.
 GDB 6.2.1
 GCC 3.3.4
 linux 2.4.20
 uclibc latest snapshot
 test program:
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
 class test{
     int testmethod();
 int main(int argc, char* argv[])
     test* test1 = new test();
 int test::testmethod()
 Compiled with: g++ -g -O2 -fPIC test.cpp
 I put a breakpoint on test::testmethod. GDB gives the following in the
 #0  test::testmethod (this=0x10011050) at test.cpp:22
 #1  0x10000608 in test::testmethod (this=0x10011050) at test.cpp:21
 #2  0x10000608 in test::testmethod (this=0x10011050) at test.cpp:21
 #3  0x10000608 in test::testmethod (this=0x10011050) at test.cpp:21
 Previous frame inner to this frame (corrupt stack?)
 It needs -O2 (or -O3) and -fPIC to do it - if you use -O, or miss off 
 the backtrace is correct.
 Does anyone have any suggestions what might be causing this?

More information about the Gdb-prs mailing list