This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

backtrace/2432: gdb does not produce correct backtrace on linux mips


>Number:         2432
>Category:       backtrace
>Synopsis:       gdb does not produce correct backtrace on linux mips
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 17 19:08:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     maxim.kozlovsky@onstor.com
>Release:        gdb 6.4.90-debian
>Organization:
>Environment:
uname -a:
Linux eng131 2.6.22-bc9k #9 Fri Nov 9 16:10:38 PST 2007 mips GNU/Linux

gcc -v
Using built-in specs.
Target: mipsel-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --disable-libssp --enable-checking=release mipsel-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)

>Description:
Debugging a core file from running the following program:

#include <malloc.h>

int main()
{
        void *p = malloc(20);
        free(p + 10);
}

produces incorrect stack trace on linux/mips:


# export LD_LIBRARY_PATH=/usr/lib/debug
#
g9r10:~# ./a.out
*** glibc detected *** free(): invalid pointer: 0x0044105a ***
Aborted (core dumped)

g9r10:~# gdb a.out
GNU gdb 6.4.90-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "mipsel-linux-gnu"...Using host libthread_db library "/usr/lib/debug/libthread_db.so.1".

(gdb) core /var/run/a.out.core
Reading symbols from /usr/lib/debug/libc.so.6...done.
Loaded symbols for /usr/lib/debug/libc.so.6
Reading symbols from /lib/ld.so.1...Reading symbols from /usr/lib/debug/lib/ld-2.3.6.so...done.
done.
Loaded symbols for /lib/ld.so.1
Core was generated by `./a.out'.
Program terminated with signal 6, Aborted.
#0  0x2ab2fb04 in kill () at ../string/bits/string2.h:998
998     ../string/bits/string2.h: No such file or directory.
        in ../string/bits/string2.h
(gdb) wher
#0  0x2ab2fb04 in kill () at ../string/bits/string2.h:998
#1  0x2ab31200 in *__GI_abort () at ../sysdeps/generic/abort.c:88
#2  0x2ab6d454 in __libc_message (do_abort=2, 
    fmt=0x2ac41a78 "*** glibc detected *** %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:145
#3  0x2ab6d454 in __libc_message (do_abort=2, 
    fmt=0x2ac41a78 "*** glibc detected *** %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:145
Previous frame identical to this frame (corrupt stack?)

After rebuilding glibc with gcc option -fno-reorder-blocks, I can get correct stack trace:

gdb a.out
GNU gdb 6.4.90-debian
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "mipsel-linux-gnu"...Using host libthread_db library "/usr/lib/debug/libthread_db.so.1".

(gdb) core /var/run/a.out.core
core /var/run/a.out.core
Reading symbols from /usr/lib/debug/libc.so.6...done.
Loaded symbols for /usr/lib/debug/libc.so.6
Reading symbols from /lib/ld.so.1...done.
Loaded symbols for /lib/ld.so.1
Core was generated by `./a.out'.
Program terminated with signal 6, Aborted.
#0  0x2ab2f104 in kill () at ../string/bits/string2.h:998
998	  while (__s[__result] != '\0' && __s[__result] != __reject1
(gdb) wher
wher
#0  0x2ab2f104 in kill () at ../string/bits/string2.h:998
#1  0x2ab3070c in *__GI_abort () at ../sysdeps/generic/abort.c:88
#2  0x2ab6b11c in __libc_message (do_abort=2, 
    fmt=0x2ac3a778 "*** glibc detected *** %s: 0x%s ***\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:145
#3  0x2ab71e7c in malloc_printerr (action=3, 
    str=0x2ac3a840 "free(): invalid pointer", ptr=<value optimized out>)
    at malloc.c:5525
#4  0x2ab73c7c in *__GI___libc_free (mem=0x44105a) at malloc.c:3404
#5  0x004006cc in main () at 1.c:8

>How-To-Repeat:
Run the following program:

#include <malloc.h>

int main()
{
        void *p = malloc(20);
        free(p + 10);
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]