Matt Schalit wrote:

> Ok.  Now I'll run the program again, and
> then step through the functions in send_ping()
> with a while loop.  The numbers are the line
> numbers in gatping.c.
> 
> ----------------------------------------------------------------
> (gdb) run
> Starting program: /tmp/gatping
> warning: Unable to find dynamic linker breakpoint function.
> warning: GDB will be unable to debug shared library initializers
> warning: and track explicitly loaded dynamic code.
> 
> Breakpoint 1, send_ping (s=5, h=0x804a958) at gatping.c:161
> Source file is more recent than executable.
> 161             /* gettimeofday ( &h->last_send_time, &tz )     ; */
> (gdb) while 1
>  > step
>  > end

> 179                     printf ( "Problem with ping - returned %d\n",n )  ;
> 182
> 185
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x17f0c4 in   ()
> Single stepping until exit from function __libc_free,
> which has no line number information.
> 
> Program terminated with signal SIGSEGV, Segmentation fault.
> The program no longer exists.
> The program is not being run.
> (gdb)
> ----------------------------------------------------------------------------
> 
> So I'm figuring something with the printf(), because there
> ain't no printf'ing going on that I see.

However, you didn't mention lines 182 and 185; for these lines I get:

182             if ( n < 0 || n != ping_pkt_size )
185             free ( buffer ) ;

Here's a debugging session:

Script started on Wed Oct 31 09:53:02 2001
# gdb ./gatping
GNU gdb 19991004
Copyright 1998 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 "i386-redhat-linux"...
(gdb) break send_ping
Breakpoint 1 at 0x8048878: file gatping.c, line 161.
(gdb) r
Starting program:
/pub/oxygen/src/net/gatping/EchoWare_0.46/gatping_0.2/./gatping

Breakpoint 1, send_ping (s=5, h=0x804ac58) at gatping.c:161
161             buffer = ( char * ) malloc ( ( size_t ) ping_pkt_size )
;
(gdb) n
162             memset ( buffer, 0, ping_pkt_size * sizeof ( char ) )  
;
(gdb) p buffer
$1 = 0x804a398 "P\235\020@P\235\020@\020"
(gdb) n
166             icp->icmp_type = ICMP_ECHO      ;
(gdb) p buffer
$2 = 0x804a398 ""
(gdb) n
167             icp->icmp_code = 0              ;
(gdb) n
168             icp->icmp_cksum = 0             ;
(gdb) n
169             icp->icmp_seq = 1               ;
(gdb) n
170             icp->icmp_id = ident            ;
(gdb) n
173             gettimeofday (&pdp->ping_ts, &tz )      ;
(gdb) n
174             pdp->ping_count = 1             ;
(gdb) n
175             icp->icmp_cksum = ( in_cksum ( ( u_short * ) icp,
ping_pkt_size ) ) ;
(gdb) n
179             n = sendto ( mysock , buffer, ping_pkt_size, 0,
(gdb) p buffer
$3 = 0x804a398 "\b"
(gdb) n
182             if ( n < 0 || n != ping_pkt_size )
(gdb) p n
$4 = 8
(gdb) p ping_pkt_size
$5 = 8
(gdb) n
185             free ( buffer ) ;
(gdb) p buffer
$6 = 0x804a398 "\b"
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x400750c4 in chunk_free (ar_ptr=0x40109d40, p=0x804a390) at
malloc.c:3100
3100    malloc.c: No such file or directory.
(gdb) quit
The program is running.  Exit anyway? (y or n) y
# exit

Script done on Wed Oct 31 09:54:22 2001

Looks to me like the call to free(3) is failing, but I can't see why. 
Buffer is char * and is allocated up above, and doesn't seem to be
free'd elsewhere.

_______________________________________________
Leaf-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-devel

Reply via email to