This is the mail archive of the gdb@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]

SIGSEGV / Need help with bt output


Hello everybody,

yesterday I was facing a problem. A system function gethostbyname() that 
expects one argument, a const char* causes a segmentation fault. 

The function call code is - probably not saying much - the following:

char *http_send_recv(char *hostname, char *request)
{
ÂÂÂstructÂhostentÂ*hptr;ÂÂÂ
 Â...
ÂÂÂif(ÂhptrÂ=Âgethostbyname(ÂhostnameÂ))
ÂÂÂÂÂÂmemcpy(&sin.sin_addr,Âhptr->h_addr,Âhptr->h_length);
ÂÂÂelse
ÂÂÂ{Â/*ÂerrorÂ*/Â}
 Â...
}

Following are TWO output snippets from two different Linux boxes (Suse/Debian)

gdb output (SuSE):
(gdb) s
   5701:   symbol=gethostbyname; Âlookup in 
file=/home/oblock/programming/c/tcp/ddnscli
   5701:   symbol=gethostbyname; Âlookup in file=/lib/tls/libc.so.6
lookup 0x08048000 0x00000284 -> 0x40034000 0x000c9ae0 /1 gethostbyname
   5701:   symbol=malloc; Âlookup in 
file=/home/oblock/programming/c/tcp/ddnscli
   5701:   symbol=malloc; Âlookup in file=/lib/tls/libc.so.6

Program received signal SIGSEGV, Segmentation fault.
0x40007b46 in do_lookup_x () from /lib/ld-linux.so.2
(gdb) bt
#0 Â0x40007b46 in do_lookup_x () from /lib/ld-linux.so.2
#1 Â0x400084ae in _dl_lookup_symbol_x () from /lib/ld-linux.so.2
#2 Â0x4000cc26 in fixup () from /lib/ld-linux.so.2
#3 Â0x4000c9f0 in _dl_runtime_resolve () from /lib/ld-linux.so.2
#4 Â0x400fdb3f in gethostbyname () from /lib/tls/libc.so.6
#5 Â0x08048d1b in http_send_recv (hostname=0x804916b "www.oliver-block.eu",
  request=0x804914f "GET /checkip.php /HTTP1.1\r\n") at ddnscli.c:161
#6 Â0x08048e12 in get_ip () at ddnscli.c:191
#7 Â0x08048f01 in main (argc=6, argv=0xbffff174) at ddnscli.c:243
(gdb) Â Â Â Â 
################################################
output (Debian):

Program received signal SIGSEGV, Segmentation fault.
0x40011a14 in realloc () from /lib/ld-linux.so.2
(gdb) bt
#0  0x40011a14 in realloc () from /lib/ld-linux.so.2
#1  0x40006381 in _dl_map_object () from /lib/ld-linux.so.2
#2  0x40123e3a in getutmpx () from /lib/libc.so.6
#3  0x4000c016 in _dl_catch_error () from /lib/ld-linux.so.2
#4  0x40124676 in _dl_open () from /lib/libc.so.6
#5  0x401259b3 in _dl_mcount_wrapper_check () from /lib/libc.so.6
#6  0x4000c016 in _dl_catch_error () from /lib/ld-linux.so.2
#7  0x4012596e in _dl_mcount_wrapper_check () from /lib/libc.so.6
#8  0x40125a68 in __libc_dlopen_mode () from /lib/libc.so.6
#9  0x40104478 in __nss_lookup_function () from /lib/libc.so.6
#10 0x4010403f in __nss_database_lookup () from /lib/libc.so.6
#11 0x40105e73 in __nss_hostname_digits_dots () from /lib/libc.so.6
#12 0x401095c8 in getservbyname_r () from /lib/libc.so.6
#13 0x40109416 in getservbyname () from /lib/libc.so.6
#14 0x08048d34 in http_send_recv (hostname=0x804919b "www.oliver-block.eu",
    request=0x804917f "GET /checkip.php /HTTP1.1\r\n") at ddnscli.c:166
#15 0x08048e14 in get_ip () at ddnscli.c:191
#16 0x08048ef6 in main (argc=5, argv=0xbffffb24) at ddnscli.c:243
(gdb)


Help is appreciated.

Best regards,

Oliver

-- 
Leben ist mehr als ... 
<http://www.nak-nrw.de/index.php?id=71>


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