[rrd-developers] Re: rrdtool libraries segfault with getopt

Brian_Teravskis at cargill.com Brian_Teravskis at cargill.com
Fri Apr 4 15:44:23 MEST 2003


Markus,
I had a similar problem about two weeks ago and I found that I had to
set optind (a global variable) to zero every time you call an rrd
functions. Example:

optind = 0; opterr = 0;

  if( ::rrd_create(len, temp_create_string) ) {

[...]

My feeling is this should be done in the library, or a library function
should be provided to do this. As you can see I also set the variable
opterr to zero as well. If you look at the php rrd code you will see the
same technique.

I hope this helps.

Regards and good luck,

Brian

-----Original Message-----
From: markus at markus.org [mailto:markus at markus.org]
Sent: Thursday, April 03, 2003 2:32 PM
To: rrd-developers at list.ee.ethz.ch
Subject: [rrd-developers] rrdtool libraries segfault with getopt



I'm developping an app in C which is calling rrd_update and rrd_create
directly (linking with librrd). So far things are working, but there
is a problem if I mix calls to rrd_create and rrd_update. The rrd_update
call generates a segfault and my app is dead :-(.

Searching through the mailing list yields a hit 
(http://www.ee.ethz.ch/~slist/rrd-developers/msg00481.html)
with somebody having the same problem back in 2001. Unfortunately
there is no follow-up.

My problem seems to be the same: The way rrdtool uses getopt is not
clean. In my app I already had to resort to my own commandline
routine as using getopt myself and then calling rrd_update got
a segfault too. Unfortunately this workaround does not help if
separate rrdtool routines can not work within the same program.

Here my backtrace:
(gdb) bt
#0  0x4016f8ec in _getopt_internal () from /lib/libc.so.6
#1  0x401708f3 in getopt_long () from /lib/libc.so.6
#2  0x4003212b in rrd_update () from /usr/lib/librrd.so.0
#3  0x080494b6 in rrd_update_data (rrd_name=0x804a0a3 "cpu",
    rrd_data=0xbffff730 "1049186901:0.0:4") at rrdmon.c:209
#4  0x08049646 in rrd_stats () at rrdmon.c:236
#5  0x08049981 in main (argc=2, argv=0xbffffbbc) at rrdmon.c:314
#6  0x400c09c4 in __libc_start_main () from /lib/libc.so.6

Any ideas ?

Markus


--
  Markus Baertschi             Phone: ++41 (21) 807 1677
  Bas du Rossé 14b             Fax  : ++41 (21) 807 1678
  CH-1163, Etoy                Email: markus at markus.org
  Switzerland                  Homepage: www.markus.org





--
  Markus Baertschi             Phone: ++41 (21) 807 1677
  Bas du Rossé 14b             Fax  : ++41 (21) 807 1678
  CH-1163, Etoy                Email: markus at markus.org
  Switzerland                  Homepage: www.markus.org


--
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



--
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