Nope, you've mostly missed the point of my instructions...

you use the frame command in gdb to set which stack frame is "current" so
that commands like list and print work in THAT context...  the default is
frame 0, where the failure occurred, and that's deep into malloc.c

You begin to get the point with this:

(gdb) print ar_ptr
$10 = (arena *) 0x40612620
(gdb) print p
$11 = 0x8793968

But they're variables deep in malloc.c and a) I don't have the source and b)
don't care - I know what's wrong - it's trying to free something that wasn't
allocated.  What I don't know is what & why - and that's what locked up in
the scanTimedoutTCPSessions() and freeSession() variables...

Basically, what you have to do is to follow the code and print what seems to
be related...

(gdb) info stack
#0  0x4055ee9c in chunk_free (ar_ptr=0x40612620, p=0x8793968) at
malloc.c:3228
#1  0x4055ebf4 in __libc_free (mem=0x8793970) at malloc.c:3154
#2  0x40284c55 in ntop_safefree (ptr=0x41ad29dc, file=0x402a55b9
"sessions.c", line=246) at leaks.c:485
#3  0x402905cf in freeSession (sessionToPurge=0x8793970, actualDeviceId=0,
allocateMemoryIfNeeded=1 '\001')
    at sessions.c:246
#4  0x40290784 in scanTimedoutTCPSessions (actualDeviceId=0) at
sessions.c:310
#5  0x4028107e in purgeIdleHosts (actDevice=0) at hash.c:471
#6  0x40286909 in scanIdleLoop (notUsed=0x0) at ntop.c:619
#7!   0x4022fb9c in pthread_start_thread (arg=0x41ad2be0) at manager.c:274
#8  0x4022fc7f in pthread_start_thread_event (arg=0x41ad2be0) at
manager.c:298

So reversing this gives us:

scanIdleLoop() at ntop.c:619, invokes
    purgeIdleHosts (actDevice=0) at hash.c:471, invokes
        scanTimedoutTCPSessions (actualDeviceId=0) at sessions.c:310,
invokes
            freeSession (sessionToPurge=0x8793970, actualDeviceId=0,
allocateMemoryIfNeeded=1 '\001')

OK?  Follow me so far?

sure enough, 310 in sessions.c is

        freeSession(thisSession, actualDeviceId, 1);

thisSession (called sessionToPurge in freeSession()) is defined as
"IPSession *".  So one question is what's in that session... (it's defined
in ntop.h, 1480->1516)

What you should do is
(gdb) frame 3
(gdb) list

this will now show you the code in for the call to free() in freeSession()
in sessions.c

then do

(gdb) print sessionToPurge
(gdb) print *sessionToPurge

This should give us the contents of the IPSession variable that's being
purged...

then do

(gdb) frame 4

which makes the current frame the one in scanTimedoutTCPSessions, and again
you can list and print variable values...



-----Burton


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of patrick
wong
Sent: Thursday, May 30, 2002 11:48 AM
To: [EMAIL PROTECTED]
Subject: RE: [Ntop] Suspicious FTP message from ntop


Hello,
Here is the back trace (or info stack) on the thread that's dying and the
frame command to point at the last place in ntop code. Also included is the
list and print command. I hope this is helpful. Please let me know how to
interpret and any assistance would be greatly appreciated.
Regards, Patrick

[root@localhost ntopuser]# gdb /usr/local/bin/ntop
GNU gdb Red Hat Linux 7.x (5.0rh-15) (MI_OUT)
Copyright 2001 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) set args -u root -P /home/ntopuser -i eth0 -K
(gdb) run
Starting program: /usr/local/bin/ntop -u root -P /home/ntopuser -i eth0 -K
[New Thread 1024 (LWP 13670)]
Wait please: ntop is coming up...
30/May/2002 11:08:45 Initializing IP services...
SSL is present but https is disabled: use -W <https port> for enabling it
30/May/2002 11:08:45 Initializing GDBM...
30/May/2002 11:08:45 Initializing network devices...
30/May/2002 11:08:45 ntop v.2.0.99 MT ! (SSL) [i686-pc-linux-gnu] (05/30/02
09:39:29 AM build)
30/May/2002 11:08:45 Listening on [eth0]
30/May/2002 11:08:45 Copyright 1998-2002 by Luca Deri <[EMAIL PROTECTED]>
30/May/2002 11:08:45 Get the freshest ntop from http://www.ntop.org/
30/May/2002 11:08:45 Initializing...
30/May/2002 11:08:45 Truncated network size to 1024 hosts (real netmask
255.255.0.0)
30/May/2002 11:08:45 Loading plugins (if any)...
30/May/2002 11:08:45 Searching plugins in /usr/local/lib/ntop/plugins
30/May/2002 11:08:47 Welcome to icmpWatchPlugin. (C) 1999 by Luca Deri.
30/May/2002 11:08:48 Welcome to LastSeenWatchPlugin. (C) 1999 by Andrea
Marangoni.
30/May/2002 11:08:50 Welcome to NetFlow. (C) 2002 by Luca Deri.
30/May/2002 11:08:53 Welcome to nfsWatchPlugin. (C) 1999 by Luca Deri.
30/May/2002 11:08:55 Welcome to PDAPlugin. (C) 2001-2002 by L.Deri and
W.Brock
30/May/2002 11:08:57 Welcome ! to sFlowPlugin. (C) 2002 by Luca Deri.
30/May/2002 11:08:57 Resetting traffic statistics...
[New Thread 2049 (LWP 13678)]
[New Thread 1026 (LWP 13679)]
30/May/2002 11:08:58 Started thread (1026) for network packet analyser.
[New Thread 2051 (LWP 13680)]
30/May/2002 11:08:58 Started thread (2051) for idle hosts detection.
[New Thread 3076 (LWP 13681)]
30/May/2002 11:08:59 Started thread (3076) for DNS address resolution.
[New Thread 4101 (LWP 13682)]
30/May/2002 11:08:59 Started thread (4101) for address purge.
30/May/2002 11:08:59 Initializing plugins (if any)...
30/May/2002 11:08:59 NetFlow export disabled
30/May/2002 11:08:59 Waiting for HTTP connections on port 3000...
[New Thread 5126 (LWP 13683)]
30/May/2002 11:08:59 Started thread (5126) for web server.
30/May/2002 11:08:59 Sniffying...
[New Thread 6151 (LWP 13684)]
30/May/2002 11:08:59 Extending hash size [newSize=512][deviceId=0]
30/May/2002 11:09:00 Started th! read (6151) for network packet sniffing on
eth0.
30/May/2002 11:09:24 Extending hash size [newSize=1024][deviceId=0]
30/May/2002 11:10:04 Extending hash size [newSize=2048][deviceId=0]
30/May/2002 11:11:34 Extending hash size [newSize=4096][deviceId=0]
30/May/2002 11:14:34 Extending hash size [newSize=8192][deviceId=0]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 2051 (LWP 13680)]
0x4055ee9c in chunk_free (ar_ptr=0x40612620, p=0x8793968) at malloc.c:3228
3228    malloc.c: No such file or directory.
        in malloc.c
(gdb)
(gdb)
(gdb) info stack
#0  0x4055ee9c in chunk_free (ar_ptr=0x40612620, p=0x8793968) at
malloc.c:3228
#1  0x4055ebf4 in __libc_free (mem=0x8793970) at malloc.c:3154
#2  0x40284c55 in ntop_safefree (ptr=0x41ad29dc, file=0x402a55b9
"sessions.c", line=246) at leaks.c:485
#3  0x402905cf in freeSession (sessionToPurge=0x8793970, actualDeviceId=0,
allocateMemoryIfNeeded=1 '\001')
    at sessions.c:246
#4  0x40290784 in scanTimedoutTCPSessions (actualDeviceId=0) at
sessions.c:310
#5  0x4028107e in purgeIdleHosts (actDevice=0) at hash.c:471
#6  0x40286909 in scanIdleLoop (notUsed=0x0) at ntop.c:619
#7!   0x4022fb9c in pthread_start_thread (arg=0x41ad2be0) at manager.c:274
#8  0x4022fc7f in pthread_start_thread_event (arg=0x41ad2be0) at
manager.c:298
(gdb) frame
#0  0x4055ee9c in chunk_free (ar_ptr=0x40612620, p=0x8793968) at
malloc.c:3228
3228    in malloc.c
(gdb) list
3223    in malloc.c
(gdb) print ar_ptr
$1 = (arena *) 0x40612620
(gdb) print p
$2 = 0x8793968
(gdb)
$3 = 0x8793968
(gdb)
$4 = 0x8793968
(gdb)
$5 = 0x8793968
(gdb)
$6 = 0x8793968
(gdb)
$7 = 0x8793968
(gdb)
$8 = 0x8793968
(gdb)
$9 = 0x8793968
(gdb) list
3223    in malloc.c
(gdb) info stack
#0  0x4055ee9c in chunk_free (ar_ptr=0x40612620, p=0x8793968) at
malloc.c:3228
#1  0x4055ebf4 in __libc_free (mem=0x8793970) at malloc.c:3154
#2  0x40284c55 in ntop_safefree (ptr=0x41ad29dc, file=0x402a55b9
"sessions.c", line=246) at leaks.c:485
#3  0x402! 905cf in freeSession (sessionToPurge=0x8793970, actualDeviceId=0,
allocateMemoryIfNeeded=1 '\001')
    at sessions.c:246
#4  0x40290784 in scanTimedoutTCPSessions (actualDeviceId=0) at
sessions.c:310
#5  0x4028107e in purgeIdleHosts (actDevice=0) at hash.c:471
#6  0x40286909 in scanIdleLoop (notUsed=0x0) at ntop.c:619
#7  0x4022fb9c in pthread_start_thread (arg=0x41ad2be0) at manager.c:274
#8  0x4022fc7f in pthread_start_thread_event (arg=0x41ad2be0) at
manager.c:298
(gdb) print ar_ptr
$10 = (arena *) 0x40612620
(gdb) print p
$11 = 0x8793968
(gdb)



>From: "Burton M. Strauss III"
>To:
>CC:
>Subject: RE: [Ntop] Suspicious FTP message from ntop
>Date: Thu, 30 May 2002 09:37:08 -0500
>
>Fine... how about doing the back trace... (info stack) on the thread that's
>dying... then use the frame command to point at the last place in ntop
code.
>Then the list will be meaningful. Also, print requires a variable name...
>
>-----Burton
>
>
>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of patrick
>wong
>Sent: Thursday, May 30, 2002 9:23 AM
>To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
>Subject: RE: [Ntop] Suspicious FTP message from ntop
>
>
>Hello,
>I have a new error now. I get the following segmentation fault from the
>lastest build of Ntop. Ntop is a compiled build of ntop-02-05-30.tgz
>It looks like Ntop is having segmentation faults at malloc.c. Any
assistance
>would appreciated.
>Regards, Patrick
>
>
>[root@localhost ntopuser]# gdb /usr/local/bin/ntop
>GNU gdb Red Hat Linux 7.x (5.0rh-15) (MI_OUT)
>Copyright 2001 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) set args -u root -i eth0 -P /home/ntopuser -K
>(gdb) run
>Starting program: /usr/local/bin/ntop -u root -i eth0 -P /home/ntopuser -K
>[New Thread 1024 (LWP 13543)]
>Wait please: ntop is coming up...
>30/May/2002 10:20:22 Initializing IP services...
>SSL is present but https is disabled: use -W for enabling it
>30/May/2002 10:20:22 Initializing GDBM...
>30/May/2002 10:20:22 Initializing network devices...
>30/May/2002 10:20:22 ntop v.2.0.99 MT ! (SSL) [i686-pc-linux-gnu] (05/30/02
>09:39:29 AM build)
>30/May/2002 10:20:22 Listening on [eth0]
>30/May/2002 10:20:22 Copyright 1998-2002 by Luca Deri
>30/May/2002 10:20:22 Get the freshest ntop from http://www.ntop.org/
>30/May/2002 10:20:22 Initializing...
>30/May/2002 10:20:22 Truncated network size to 1024 hosts (real netmask
>255.255.0.0)
>30/May/2002 10:20:22 Loading plugins (if any)...
>30/May/2002 10:20:22 Searching plugins in /usr/local/lib/ntop/plugins
>30/May/2002 10:20:24 Welcome to icmpWatchPlugin. (C) 1999 by Luca Deri.
>30/May/2002 10:20:26 Welcome to LastSeenWatchPlugin. (C) 1999 by Andrea
>Marangoni.
>30/May/2002 10:20:28 Welcome to NetFlow. (C) 2002 by Luca Deri.
>30/May/2002 10:20:30 Welcome to nfsWatchPlugin. (C) 1999 by Luca Deri.
>30/May/2002 10:20:32 Welcome to PDAPlugin. (C) 2001-2002 by L.Deri and
>W.Brock
>30/May/2002 10:20:35 Welcome ! to sFlowPlugin. (C) 2002 by Luca Deri.
>30/May/2002 10:20:35 Resetting traffic statistics...
>[New Thread 2049 (LWP 13550)]
>[New Thread 1026 (LWP 13551)]
>30/May/2002 10:20:36 Started thread (1026) for network packet analyser.
>[New Thread 2051 (LWP 13552)]
>30/May/2002 10:20:36 Started thread (2051) for idle hosts detection.
>[New Thread 3076 (LWP 13553)]
>30/May/2002 10:20:36 Started thread (3076) for DNS address resolution.
>[New Thread 4101 (LWP 13554)]
>30/May/2002 10:20:37 Started thread (4101) for address purge.
>30/May/2002 10:20:37 Initializing plugins (if any)...
>30/May/2002 10:20:37 NetFlow export disabled
>30/May/2002 10:20:37 Waiting for HTTP connections on port 3000...
>[New Thread 5126 (LWP 13555)]
>30/May/2002 10:20:37 Started thread (5126) for web server.
>30/May/2002 10:20:37 Sniffying...
>[New Thread 6151 (LWP 13556)]
>30/May/2002 10:20:37 Extending hash size [newSize=512][deviceId=0]
>30/May/2002 10:20:38 Started th! read (6151) for network packet sniffing on
>eth0.
>30/May/2002 10:20:58 Extending hash size [newSize=1024][deviceId=0]
>30/May/2002 10:21:28 Extending hash size [newSize=2048][deviceId=0]
>30/May/2002 10:22:48 Extending hash size [newSize=4096][deviceId=0]
>30/May/2002 10:25:48 Extending hash size [newSize=8192][deviceId=0]
>Program received signal SIGSEGV, Segmentation fault.
>[Switching to Thread 2051 (LWP 13552)]
>0x4055ee9c in chunk_free (ar_ptr=0x40612620, p=0x93bcc68) at malloc.c:3228
>3228 malloc.c: No such file or directory.
> in malloc.c
>(gdb) list
>3223 in malloc.c
>(gdb) print
>The history is empty.
>(gdb) list
>3223 in malloc.c
>(gdb) thread
>[Current thread is 4 (Thread 2051 (LWP 13552))]
>(gdb) thread
>[Current thread is 4 (Thread 2051 (LWP 13552))]
>(gdb) thread 1
>[Switching to thread 1 (Thread 1024 (LWP 13543))]#0 0x405989e7 in
>__libc_pause () from /lib/i686/libc.so.6
>(gdb) list
>3223 in malloc.c
>(gdb) print
>The history is empty.
>(gdb) thread 2
>[Switching to thread 2 (Thread 2049 (LWP 13550))]#0 0x405c39f7 in __poll
>(fds=0x82a99cc, nfds=1, timeout=2000)
> at ../sysdeps/unix/sysv/linu! x/poll.c:63
>63 ../sysdeps/unix/sysv/linux/poll.c: No such file or directory.
> in ../sysdeps/unix/sysv/linux/poll.c
>(gdb) list
>58 in ../sysdeps/unix/sysv/linux/poll.c
>(gdb) list 3
>1 in ../sysdeps/unix/sysv/linux/poll.c
>(gdb) list
>1 in ../sysdeps/unix/sysv/linux/poll.c
>(gdb) thread 3
>[Switching to thread 3 (Thread 1026 (LWP 13551))]#0 0x4050caa5 in
>__sigsuspend (set=0x412d263c)
> at ../sysdeps/unix/sysv/linux/sigsuspend.c:45
>45 ../sysdeps/unix/sysv/linux/sigsuspend.c: No such file or directory.
> in ../sysdeps/unix/sysv/linux/sigsuspend.c
>(gdb) list
>40 in ../sysdeps/unix/sysv/linux/sigsuspend.c
>(gdb)
>40 i! n ../sysdeps/unix/sysv/linux/sigsuspend.c
>(gdb)
>40 in ../sysdeps/unix/sysv/linux/sigsuspend.c
>(gdb) thread 4
>[Switching to thread 4 (Thread 2051 (LWP 13552))]#0 0x4055ee9c in
>chunk_free (ar_ptr=0x40612620, p=0x93bcc68)
> at malloc.c:3228
>3228 malloc.c: No such file or directory.
> in malloc.c
>(gdb) list
>3223 in malloc.c
>(gdb)
>
>
>
>
>Send and receive Hotmail on your mobile device: Click Here
>_______________________________________________ Ntop mailing list
>[EMAIL PROTECTED] http://listgateway.unipi.it/mailman/listinfo/ntop
>



MSN Photos is the easiest way to share and print your photos: Click Here
_______________________________________________ Ntop mailing list
[EMAIL PROTECTED] http://listgateway.unipi.it/mailman/listinfo/ntop

_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop

Reply via email to