Well, if it's erroring vs. eof...

This extract from man fgets:

RETURN VALUES
     Upon successful completion, fgets() and gets() return a pointer to the
     string.  If end-of-file occurs before any characters are read, they
     return NULL and the buffer contents is unchanged.  If an error occurs,
     they return NULL and the buffer contents is indeterminate.  The fgets()
     and gets() functions do not distinguish between end-of-file and error,
     and callers must use feof(3) and ferror(3) to determine which occurred.

ERRORS
     [EBADF]            The given stream is not a readable stream.

     The function fgets() may also fail and set errno for any of the errors
     specified for the routines fflush(3), fstat(2), read(2), or malloc(3).

     The function gets() may also fail and set errno for any of the errors
     specified for the routine getchar(3).


Stanley, try dumping a test and trace into the lines in initialize.c @ 245
(remember to add the {} too).  Make it look like this:

        if (fgets(buff, sizeof(buff), fd)==NULL) {
          if (errno != 0) {
              traceEvent(CONST_TRACE_ERROR, "IP2CC: error reading file,
%s(%d).",
                         strerror(errno), errno);
              traceEvent(CONST_TRACE_INFO, "IP2CC: ntop continues OK, but
with partial file");
              break;
          }
          continue;
        }

(I **THINK** that will compile ok)

-----Burton


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of
Stanley Hopcroft
Sent: Friday, March 28, 2003 4:25 PM
To: [EMAIL PROTECTED]
Subject: Re: [Ntop] Bug report with 2.1.90. One installation (of 6)
hangs at start: 100% CPU.


Dear Sir,

I am writing to thank you for your letter and say,

On Thu, Mar 27, 2003 at 04:09:42PM -0600, Burton M. Strauss III wrote:

  .. snip ..
>
> When it's hung up, can you attach to it via gdb and see where it's
looping?
>
> gdb /usr/bin/ntop pid
>
> followed by the usual bt full, info stack, info thread etc.
>




> -----Burton
>
>
tsper# gdb /usr/local/ntop/bin/ntop 90213
GNU gdb 4.18 (FreeBSD)
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-unknown-freebsd"...Deprecated bfd_read
called at
/usr/src/gnu/usr.bin/binutils/gdb/../../../../contrib/gdb/gdb/dbxread.c
line 2627 in elfstab_build_psymtabs
Deprecated bfd_read called at
/usr/src/gnu/usr.bin/binutils/gdb/../../../../contrib/gdb/gdb/dbxread.c
line 933 in fill_symbuf


/root/90213: No such file or directory.
Attaching to program: /usr/local/ntop/bin/ntop, process 90213
Reading symbols from
/usr/local/ntop-2.1.90/lib/libntopreport-2.1.90.so...done.
Reading symbols from
/usr/local/ntop-2.1.90/lib/libntop-2.1.90.so...done.
Reading symbols from /usr/lib/libc_r.so.4...done.
Reading symbols from /usr/lib/libm.so.2...done.
Reading symbols from /usr/lib/libz.so.2...done.
Reading symbols from /usr/lib/libssl.so.2...done.
Reading symbols from /usr/lib/libcrypto.so.2...done.
Reading symbols from /usr/lib/libc.so.4...done.
Reading symbols from /usr/lib/libcrypt.so.2...done.
Reading symbols from /usr/lib/libpcap.so.2...done.
Reading symbols from /usr/local/lib/libgdbm.so.2...done.
Reading symbols from
/usr/local/ntop-2.1.90/lib/ntop/plugins/icmpPlugin.so...done.
Reading symbols from
/usr/local/ntop-2.1.90/lib/ntop/plugins/lastSeenPlugin.so...done.
Reading symbols from
/usr/local/ntop-2.1.90/lib/ntop/plugins/netflowPlugin.so...done.
Reading symbols from
/usr/local/ntop-2.1.90/lib/ntop/plugins/nfsPlugin.so...done.
Reading symbols from
/usr/local/ntop-2.1.90/lib/ntop/plugins/pdaPlugin.so...done.
Reading symbols from
/usr/local/ntop-2.1.90/lib/ntop/plugins/sflowPlugin.so...done.
Reading symbols from
/usr/local/ntop-2.1.90/lib/ntop/plugins/rrdPlugin.so...done.
Reading symbols from /usr/local/lib/librrd.so.0...done.
Reading symbols from /usr/libexec/ld-elf.so.1...done.
0x28387f5d in fgets () from /usr/lib/libc_r.so.4
(gdb) bt full
#0  0x28387f5d in fgets () from /usr/lib/libc_r.so.4
No symbol table info available.
#1  0x2811b593 in initIPCountryTable () at initialize.c:245
        buff = '\000' <repeats 255 times>
        strtokState = 0x0
        cc = 0x0
        ip = 0x0
        prefix = 0xbfbff5cc ""
        tmpStr = "/usr/local/ntop-2.1.90/etc/ntop/p2c.opt.table", '\000'
<repeats 179 times>,
"@\211\024(�~8(`t\024(,���,���\\�\021(P�\n\b\000\000\000"
        fd = (FILE *) 0x80abf50
        idx = -1077938740
#2  0x2811c603 in initCounters () at initialize.c:715
        len = 672434496
        i = 1
        fd = (FILE *) 0x28140f80
        configFileFound = 1
        buf =
"/usr/local/ntop-2.1.90/etc/ntop/etter.passive.os.fp\000\024\000\000\000\003
\000\000\000����\013�\b(1\233\004\b3��\001\0000\n(����\001\000\000\000\0000\
n(������\b(1\233\004\b\000\000\000\000\000\000\000\000\202�\b(��\t(\0000\n(L
�\n\b����]�\021(\000\2207\b�\000\000\000�\216\004\b\031�\021\001\0002\n(\b��
�L�\b(m\000\000\000\0000\n(\b���\177�\b(\200P\n(�p\024(\b���\e�\b(\\�\n\b"..
.
#3  0x804d1f2 in main (argc=16, argv=0xbfbffbf0) at main.c:1138
        i = 1
        rc = 134922064
        userSpecified = 1
        bufLen = 672434496
        effective_argc = 672434496
        effective_argv = (char **) 0xbfbffad9
        ifStr = "fxp0", '\000' <repeats 191 times>
        lastTime = 1048867151
        startedAs = 0x80c2000 "/usr/local/ntop/bin/ntop -o -c -u nobody
-d -P /var/log/ntop -w 3000 -i fxp0 -p
HTTP=http|https,DNS=domain,Ntop=3000,NBios-IP=netbios-ns|netbios-dgm|netbios
-ssn,Mail=lotusnote|pop2|pop3|kpop|smtp|imap"...
        cmdLineBuffer = 0x0
        readBuffer = 0x0
        readBufferWork = 0x28148940 "��\n\be`\001"
        fd = (FILE *) 0x28090ada
        fileStat = {st_dev = 3217029860, st_ino = 1, st_mode = 64232,
st_nlink = 49087, st_uid = 674963084, st_gid = 11, st_rdev = 671756288,
st_atimespec = {tv_sec = 671756544, tv_nsec = 671756800},
  st_mtimespec = {tv_sec = 671757056, tv_nsec = -1077937460},
st_ctimespec = {tv_sec = 674906281, tv_nsec = 675047768}, st_size =
2885190804845491400, st_blocks = 2898944372462207108,
  st_blksize = 671680538, st_flags = 671741128, st_gen = 671756288,
st_lspare = 134519980, st_qspare = {-4629705931003136824, 4969873618}}
#4  0x804b275 in _start ()
No symbol table info available.
(gdb) info stack
#0  0x28387f5d in fgets () from /usr/lib/libc_r.so.4
#1  0x2811b593 in initIPCountryTable () at initialize.c:245
#2  0x2811c603 in initCounters () at initialize.c:715
#3  0x804d1f2 in main (argc=16, argv=0xbfbffbf0) at main.c:1138
#4  0x804b275 in _start ()
(gdb) info thread
* 1 process 90213, thread 1  0x28387f5d in fgets () from
/usr/lib/libc_r.so.4
(gdb) s
Single stepping until exit from function fgets,
which has no line number information.
0x2832da0c in _init () from /usr/lib/libc_r.so.4
(gdb)
Single stepping until exit from function _init,
which has no line number information.
0x28388044 in fgets () from /usr/lib/libc_r.so.4
(gdb)
Single stepping until exit from function fgets,
which has no line number information.
0x2811407c in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)
Single stepping until exit from function _init,
which has no line number information.
initIPCountryTable () at initialize.c:245
245             if (fgets(buff, sizeof(buff), fd)==NULL)
(gdb)
0x28113fac in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)
Single stepping until exit from function _init,
which has no line number information.
0x2811407c in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)
Single stepping until exit from function _init,
which has no line number information.
initIPCountryTable () at initialize.c:245
245             if (fgets(buff, sizeof(buff), fd)==NULL)
(gdb)
0x28113fac in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)
Single stepping until exit from function _init,
which has no line number information.
0x2811407c in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)
Single stepping until exit from function _init,
which has no line number information.
initIPCountryTable () at initialize.c:245
245             if (fgets(buff, sizeof(buff), fd)==NULL)
(gdb)
0x28113fac in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)
Single stepping until exit from function _init,
which has no line number information.
0x2811407c in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)
Single stepping until exit from function _init,
which has no line number information.
initIPCountryTable () at initialize.c:245
245             if (fgets(buff, sizeof(buff), fd)==NULL)
(gdb)
0x28113fac in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)
Single stepping until exit from function _init,
which has no line number information.
0x2811407c in _init () from /usr/local/ntop-2.1.90/lib/libntop-2.1.90.so
(gdb)

It appears to be looping on the fgets() == NULL; continue. I can't
imagine why the feof() doesn't arrest it.

The box is not a server (apart from ntops web server and sshd).

tsper> ll /usr/local/ntop/etc/ntop/
total 904
-rw-r--r--  1 anwsmh  anwsmh   57336 Feb  4 18:03 etter.passive.os.fp
-rw-r--r--  1 anwsmh  anwsmh    1977 Jan  2  2002 ntop-cert.pem
-rwxr-xr-x  1 anwsmh  anwsmh    2811 Mar  7 04:25 oui.txt
-rw-r--r--  1 anwsmh  anwsmh  845404 Jan 30 22:34 p2c.opt.table
-rwxr-xr-x  1 anwsmh  anwsmh    2998 Mar  7 04:25 specialMAC.txt
tsper> head /usr/local/ntop/etc/ntop/p2c.opt.table
UK:2.6.190.56/29
US:3.0.0.0/8
US:4.0.0.0/8
SE:5.163.66.80/28
US:6.0.0.0/7
IT:7.57.75.32/27
US:8.0.0.0/7
UK:9.20.0.0/17
LOC:10.0.0.0/8
US:11.0.0.0/8
tsper> tail /usr/local/ntop/etc/ntop/p2c.opt.table
JP:220.144.0.0/15
CN:220.160.0.0/11
CN:220.192.0.0/12
IN:220.224.0.0/14
SG:220.255.0.0/17
CN:221.0.0.0/15
CN:221.2.0.0/16
CN:221.3.0.0/17
DK:221.97.210.0/24
US:224.0.0.0/3
tsper>


I have added the trace switch on maximum detail. However, this may have
already been enabled.

Thank you,

Yours sincerely.

--
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------

'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'

from Meditation 17, J Donne.
_______________________________________________
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