[rrd-developers] librrd segfault

Matt George mgeorge at secureworks.net
Wed Aug 8 03:45:33 MEST 2001



greetings

i am writing an rrd-enabled application and am having a problem

it would seem that the internal getopt implementation is incorrectly
incrementing optind past the bounds of both the argc and the terminating
null pointer on the argv array.  It runs through some other data I happen to
have malloc'd already and eventually runs into garbage.

i've looked at this quite a bit and haven't been able to identify the exact
bug.  Here is the gdb info.  if anyone could help, it would be most
appreciated.

Program received signal SIGSEGV, Segmentation fault.
0x2808252b in _getopt_internal (argc=3, argv=0xbfbfadac,
optstring=0x280b5de9 "t:", longopts=0x280bcde8, longind=0xbfbface8,
    long_only=0) at getopt.c:529
529           if (optind != argc && !strcmp (argv[optind], "--"))
(gdb) bt
#0  0x2808252b in _getopt_internal (argc=3, argv=0xbfbfadac,
optstring=0x280b5de9 "t:", longopts=0x280bcde8,
    longind=0xbfbface8, long_only=0) at getopt.c:529
#1  0x28082fe8 in getopt_long (argc=3, argv=0xbfbfadac, options=0x280b5de9
"t:", long_options=0x280bcde8,
    opt_index=0xbfbface8) at getopt1.c:75
#2  0x28090fed in rrd_update (argc=3, argv=0xbfbfadac) at rrd_update.c:105
#3  0x804a7b5 in run_mon_servers (mon=0x806c000) at bkmon.c:786
#4  0x804a0d8 in run_mon (mon=0x806c000) at bkmon.c:590
#5  0x8049137 in main () at bkmon.c:202
#6  0x8048de9 in _start ()
(gdb) list
524           /* The special ARGV-element `--' means premature end of
options.
525              Skip it like a null option,
526              then exchange with previous non-options as if it were an
option,
527              then skip everything else like a non-option.  */
528
529           if (optind != argc && !strcmp (argv[optind], "--"))
530             {
531               optind++;
532
533               if (first_nonopt != last_nonopt && last_nonopt != optind)
(gdb) print optind
$1 = 7
(gdb) print argv
$2 = (char **) 0xbfbfadac
(gdb) print argv[0]
$3 = 0x805c400 "update"
(gdb) print argv[1]
$4 = 0x805c480 "/home/bk/bkrrd/10.rrd"
(gdb) print argv[2]
$5 = 0x805c500 "997233783:0"
(gdb) print argv[3]
$6 = 0x0
(gdb) print argv[4]
$7 = 0x0
(gdb) print argv[5]
$8 = 0xbfbfadc9 "0"
(gdb) print argv[6]
$9 = 0xbfbfadcb "5 packets transmitted, 5 packets received, 0% packet
loss\n"
(gdb) print argv[7]
$10 = 0x3500300a <Error reading address 0x3500300a: Bad address>
(gdb)

--
Unsubscribe mailto:rrd-developers-request at list.ee.ethz.ch?subject=unsubscribe
Help        mailto:rrd-developers-request at list.ee.ethz.ch?subject=help
Archive     http://www.ee.ethz.ch/~slist/rrd-developers
WebAdmin    http://www.ee.ethz.ch/~slist/lsg2.cgi



More information about the rrd-developers mailing list