* segmentation fault
@ 2006-11-11 1:23 Oliver Block
0 siblings, 0 replies; 6+ messages in thread
From: Oliver Block @ 2006-11-11 1:23 UTC (permalink / raw)
To: gdb
Hello,
a program causes a segmentation fault and I'd like to know if I interpret the
following gdb output correctly (text continues after output):
************************************************************************************
#1 Â 0x4012eb3f in gethostbyname () from /lib/tls/libc.so.6
No symbol table info available.
#2 Â 0x08049312 in http_send_recv (hostname=0x804a340 "www.oliver-block.eu",
  request=0x804b030 "GET /checkip.php HTTP/1.0\r\nHost:
www.oliver-block.eu\r\n\r\n") at ddnscli.c:168
    hptr = (struct hostent *) 0x804b068
    sptr = (struct servent *) 0x804b028
    sin = {sin_family = 2, sin_port = 0, sin_addr = {s_addr = 0},
 sin_zero = "\000\000\000\000\000\000\000"}
    s = 134514323
    retval = 45
    n = 0
    buflen = 1024
#3 Â 0x080498ee in get_ip (qry=0x804b008) at ddnscli.c:323
    tmp = 0x0
    r = 0x804b030 "GET /checkip.php HTTP/1.0\r\nHost:
www.oliver-block.eu\r\n\r\n"
#4 Â 0x080499fa in main (argc=3, argv=0xbffff1a4) at ddnscli.c:398
    option = 8 '\b'
    q = (struct query *) 0x804b008
(gdb) p sizeof(struct servent)
$1 = 16
****************************************************************************
When I extract
from #2:
sptr = (struct servent *) 0x804b028
from #4:
r = 0x804b030 "GET /checkip.php HTTP/1.0\r\nHost: www.oliver-block.eu\r\n\r\n"
as servent has a size of 16 bytes
804b028 + 16 = 0x804b038
These two variables seem to overlap. Do you agree?
Regards,
Oliver
--
Leben ist mehr als ...
<http://www.nak-nrw.de/index.php?id=71>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: segmentation fault
2006-11-11 20:46 ` Daniel Jacobowitz
@ 2006-11-11 21:02 ` Raúl Huertas
0 siblings, 0 replies; 6+ messages in thread
From: Raúl Huertas @ 2006-11-11 21:02 UTC (permalink / raw)
To: gdb
Daniel Jacobowitz escribió:
> On Sat, Nov 11, 2006 at 09:29:39PM +0100, Raúl Huertas wrote:
>
>> No. ;)
>> Maybe I'm wrong, but sptr is a pointer, so it uses 0x804b028 and 0x804b029.
>> The memory pointed by this pointer is the one that has size 16.
>>
>
> You're incorrect, in fact. The original poster's interpretation is
> reasonable, assuming that GDB has printed out the correct values of
> variables.
>
>
Yes, you are right, and I was incorrect:
struct servent
{
char memory[16];
};
int main()
{
servent * sptr1 = new servent;
servent * sptr2 = new servent;
servent * sptr3 = sptr1;
}
----------------
(gdb) p sptr1
$1 = (servent *) 0x804a008
(gdb) p sptr2
$2 = (servent *) 0x804a020
(gdb) p sptr3
$3 = (servent *) 0x804a008
gdb shows the content of the pointer, not the position of the pointer.
My idiot error... :*)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: segmentation fault
2006-11-11 20:29 ` Raúl Huertas
@ 2006-11-11 20:46 ` Daniel Jacobowitz
2006-11-11 21:02 ` Raúl Huertas
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-11-11 20:46 UTC (permalink / raw)
To: Raúl Huertas; +Cc: gdb
On Sat, Nov 11, 2006 at 09:29:39PM +0100, Raúl Huertas wrote:
> No. ;)
> Maybe I'm wrong, but sptr is a pointer, so it uses 0x804b028 and 0x804b029.
> The memory pointed by this pointer is the one that has size 16.
You're incorrect, in fact. The original poster's interpretation is
reasonable, assuming that GDB has printed out the correct values of
variables.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: segmentation fault
2006-11-11 1:21 Oliver Block
@ 2006-11-11 20:29 ` Raúl Huertas
2006-11-11 20:46 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: Raúl Huertas @ 2006-11-11 20:29 UTC (permalink / raw)
Cc: gdb
Oliver Block escribió:
> Hello,
> ...
> (gdb) p sizeof(struct servent)
> $1 = 16
>
> When I extract
>
> from #2:
> sptr = (struct servent *) 0x804b028
>
> from #4:
> r = 0x804b030
>
> as servent has a size of 16 bytes
>
> 804b028 + 16 = 0x804b038
>
> These two variables seem to overlap. Do you agree?
>
>
No. ;)
Maybe I'm wrong, but sptr is a pointer, so it uses 0x804b028 and 0x804b029.
The memory pointed by this pointer is the one that has size 16.
Regards,
Raul.
^ permalink raw reply [flat|nested] 6+ messages in thread
* segmentation fault
@ 2006-11-11 1:21 Oliver Block
2006-11-11 20:29 ` Raúl Huertas
0 siblings, 1 reply; 6+ messages in thread
From: Oliver Block @ 2006-11-11 1:21 UTC (permalink / raw)
To: gdb
Hello,
a program causes a segmentation fault and I'd like to know if I interpret the
following gdb output correctly (text continues after output):
************************************************************************************
#1 0x4012eb3f in gethostbyname () from /lib/tls/libc.so.6
No symbol table info available.
#2 0x08049312 in http_send_recv (hostname=0x804a340 "www.oliver-block.eu",
request=0x804b030 "GET /checkip.php HTTP/1.0\r\nHost:
www.oliver-block.eu\r\n\r\n") at ddnscli.c:168
hptr = (struct hostent *) 0x804b068
sptr = (struct servent *) 0x804b028
sin = {sin_family = 2, sin_port = 0, sin_addr = {s_addr = 0},
sin_zero = "\000\000\000\000\000\000\000"}
s = 134514323
retval = 45
n = 0
buflen = 1024
#3 0x080498ee in get_ip (qry=0x804b008) at ddnscli.c:323
tmp = 0x0
r = 0x804b030 "GET /checkip.php HTTP/1.0\r\nHost:
www.oliver-block.eu\r\n\r\n"
#4 0x080499fa in main (argc=3, argv=0xbffff1a4) at ddnscli.c:398
option = 8 '\b'
q = (struct query *) 0x804b008
(gdb) p sizeof(struct servent)
$1 = 16
****************************************************************************
When I extract
from #2:
sptr = (struct servent *) 0x804b028
from #4:
r = 0x804b030 "GET /checkip.php HTTP/1.0\r\nHost: www.oliver-block.eu\r\n\r\n"
as servent has a size of 16 bytes
804b028 + 16 = 0x804b038
These two variables seem to overlap. Do you agree?
Regards,
Oliver
^ permalink raw reply [flat|nested] 6+ messages in thread
* segmentation fault
@ 2004-06-10 21:08 John
0 siblings, 0 replies; 6+ messages in thread
From: John @ 2004-06-10 21:08 UTC (permalink / raw)
To: gdb
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=us-ascii, Size: 1443 bytes --]
Hi all:
I encounter a segmentation fault probelm. When I use
"gdb core", gdb shows that the program stops at the
following line of my code:
sprintf(pt_->buffer() + offset,
I think that line cause segmentation fault.
I want to set a breakpoint at that line and run the
code to see what happens before segmetation fault. How
can I make the program stop right before segmentation
fault happens?
I also attach some information from gdb.
Thanks a lot.
John
---------------------------------------------------------------------------------
Loaded symbols for /lib/ld-linux.so.2
#0 0x4026ecef in vfprintf () from /lib/libc.so.6
(gdb) bt
#0 0x4026ecef in vfprintf () from /lib/libc.so.6
#1 0xbfffdd04 in ?? ()
#2 0x40286fcb in vsprintf () from /lib/libc.so.6
#3 0x4027492d in sprintf () from /lib/libc.so.6
#4 0x0812226b in CMUTrace::format_mac_common(Packet*,
char const*, int) (this=0x97528b8, p=0x12ef75a0,
why=0x82cc85c "---", offset=0)
at trace/cmu-trace.cc:228
.........
(gdb) frame 4
#4 0x0812226b in CMUTrace::format_mac_common(Packet*,
char const*, int) (this=0x97528b8, p=0x12ef75a0,
why=0x82cc85c "---", offset=0)
at trace/cmu-trace.cc:228
228 sprintf(pt_->buffer() + offset,
Current language: auto; currently c++
(gdb)
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2006-11-11 21:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-11 1:23 segmentation fault Oliver Block
-- strict thread matches above, loose matches on Subject: below --
2006-11-11 1:21 Oliver Block
2006-11-11 20:29 ` Raúl Huertas
2006-11-11 20:46 ` Daniel Jacobowitz
2006-11-11 21:02 ` Raúl Huertas
2004-06-10 21:08 John
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).