[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

A question on debugging libraries



Hi,

I'm not sure if this is a bug or something I have misunderstood about
the debugging libraries.  I want to show an example of debugging a
libc call, so just simply overflowed a buffer with strcpy.

---
#include <stdio.h>
#include <string.h>
 
char *b = "A long string";
 
int main(void)
{
 
        char a[1];
        strcpy(a, b);
 
}
---

Which when I run on i386 under GDB with LD_LIBRARY_PATH=/usr/lib/debug
I get

--- gdb output on i386 ---
$ gcc -g -o test test.c
$ echo $LD_LIBRARY_PATH
/usr/lib/debug
$ gdb ./test
GNU gdb 6.0 (etc)
(gdb) r
Starting program: /home/ianw/test
 
Program received signal SIGSEGV, Segmentation fault.
0x74732067 in ?? ()
(gdb) back
#0  0x74732067 in ?? ()
#1  0x676e6972 in ?? ()
#2  0xbffffa00 in ?? ()
#3  0xbffffa0c in ?? ()
#4  0x40016c20 in ?? () from /lib/ld-linux.so.2
#5  0x00000001 in ?? ()
#6  0x080482a0 in ?? ()
---

I don't belive the strcpy has been inlined, for example it shows up in ltrace

$ ltrace ./test

__libc_start_main(0x08048364, 1, 0xbffffa04, 0x08048390, 0x080483f0
<unfinished ...>
strcpy(0xbffff9b7, "A long string") = 0xbffff9b7
--- SIGSEGV (Segmentation fault) ---
+++ killed by SIGSEGV +++

I would have expected that this would give me a good backtrace.  Is
this wrong?

-i
ianw@gelato.unsw.edu.au
http://www.gelato.unsw.edu.au

Attachment: pgpl80ngmAdD9.pgp
Description: PGP signature


Reply to: