Thread overview
[Bug 136] New: Corrupt GDB backtrace
May 11, 2006
d-bugmail
May 12, 2006
d-bugmail
May 12, 2006
Lars Ivar Igesund
Jun 01, 2006
d-bugmail
Jun 02, 2006
Thomas Kuehne
May 11, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=136

           Summary: Corrupt GDB backtrace
           Product: D
           Version: 0.157
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: oskar.linde@gmail.com


void main() {
        static int i = 0;
        while(i++ < 10)
                main();
        *(cast(int *)0) = 0;
}

On DMD 0.157 compiling with dmd -g -debug and running in gdb and printing a
backtrace gives:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208064320 (LWP 23068)]
0x0804b1fa in _Dmain () at debug.d:5
5               *(cast(int *)0) = 0;
Current language:  auto; currently minimal
(gdb) bt
#0  0x0804b1fa in _Dmain () at debug.d:5
#1  0x0012d4f8 in ?? ()
#2  0xbfffecc0 in ?? ()
#3  0x0804b1f4 in _Dmain () at debug.d:4
Previous frame inner to this frame (corrupt stack?)

Compared to DMD 0.156:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208064320 (LWP 23192)]
0x0804b1fa in _Dmain () at debug.d:5
5               *(cast(int *)0) = 0;
Current language:  auto; currently minimal
(gdb) bt
#0  0x0804b1fa in _Dmain () at debug.d:5
#1  0x0804b1f4 in _Dmain () at debug.d:4
#2  0x0804b1f4 in _Dmain () at debug.d:4
#3  0x0804b1f4 in _Dmain () at debug.d:4
#4  0x0804b1f4 in _Dmain () at debug.d:4
#5  0x0804b1f4 in _Dmain () at debug.d:4
#6  0x0804b1f4 in _Dmain () at debug.d:4
#7  0x0804b1f4 in _Dmain () at debug.d:4
#8  0x0804b1f4 in _Dmain () at debug.d:4
#9  0x0804b1f4 in _Dmain () at debug.d:4
#10 0x0804b1f4 in _Dmain () at debug.d:4
#11 0x0804b26f in main ()


-- 

May 12, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=136


bugzilla@digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME




------- Comment #1 from bugzilla@digitalmars.com  2006-05-12 03:53 -------
Many gdb's fail with the -g switch. Use -gc instead. With -gc -debug, the backtrace works fine on my machine:

gdb 5.3
i386-redhat-linux-gnu


-- 

May 12, 2006
d-bugmail@puremagic.com wrote:

> http://d.puremagic.com/bugzilla/show_bug.cgi?id=136
> 
> 
> bugzilla@digitalmars.com changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>              Status|NEW                         |RESOLVED
>          Resolution|                            |WORKSFORME
> 
> 
> 
> 
> ------- Comment #1 from bugzilla@digitalmars.com  2006-05-12 03:53 -------
> Many gdb's fail with the -g switch. Use -gc instead. With -gc -debug, the backtrace works fine on my machine:
> 
> gdb 5.3
> i386-redhat-linux-gnu
> 
> 
> --

Hmm, -gc is not listed in DMD's help ? I see it is under the linux version on http://www.digitalmars.com/d/dcompiler.html, but not if you do "dmd" on the linux command line. Looked for it on all the latest version.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource & #D: larsivi
June 01, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=136


oskar.linde@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |




------- Comment #3 from oskar.linde@gmail.com  2006-06-01 13:15 -------
Maybe this is really a GDB bug, but the error remains with -gc.

On i686-pc-linux-gnu (RedHat EL4), with all of the following gdb versions:
gdb 6.4 + d symbol demangling patches
gdb 6.4 vanilla
gdb 6.3
gdb 6.0
(I was unable to get gdb 5.3 and 5.2.1 to work on my system)

compiled with:
dmd -gc => corrupt backtrace
dmd -g => corrupt backtrace
dmd => OK backtrace

with DMD 0.156 and earlier, the back traces work fine with all above combinations.


-- 

June 02, 2006
d-bugmail@puremagic.com schrieb am 2006-06-01:
> http://d.puremagic.com/bugzilla/show_bug.cgi?id=136

> Maybe this is really a GDB bug, but the error remains with -gc.

This seems to be GDB related.

Valgrind hand no problems:
==23266== Invalid write of size 4
==23266==    at 0x804A0C0: void a.foo() (a.d:7)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0BB: void a.foo() (a.d:5)
==23266==    by 0x804A0CB: _Dmain (a.d:11)
==23266==  Address 0x0 is not stack'd, malloc'd or (recently) free'd

Thomas