[rrd-users] rrd_fetch Segmentation Fault - getopts

Francois Mikus francois.mikus at transcontinental.ca
Mon Jul 8 18:03:23 MEST 2002

Hello all,

A few messages have passed by in relation to problems with the
getopts counters that are used in parsing input to different rrd-tool

I believe fixes have been made for rrd_graph.c / RRDs::graph .
Unfortunatly, I am
running into problems within the fetch function.

Just to recap, the problem is a segmentation fault on repetitive calls
from a
perl program to an rrd_* function such as graph, update or fetch. It
seems to
be caused by opt_ind and opt_err not being reset and causing the
segfault in rdd_fetch.c. This would happen at semi-random numbers of
iterations. After, approx: 150 to 400 calls.

Within rrd_tool.c which is what calls graph, fetch and update. I was
running into problems with the calls to fetch at line 512 of rrd_tool.c.

I added:

optind = 0;
opterr = 0;

Just before the call to fetch and, voila, my program would no longer
segfault when calling fetch. The same "fix" seems to have been added in
rrd_tool.c just before the call to the graph function at line 372. The
usage of optind=0 seems to be a bit controversial in the sense some
people say it should be reset to 1, other say it should be reset to 0
before calling a function that will parse arguments using getopts

Anyways, if someone has run into the same problems, I hope this helps.
In any case, should the change make sense, feel free to submit the
change in cvs. I do not have access to it, nor do I intend to. ;-)

The diff was run against rrd_tool.c from the CVS snapshot of RRDtool
1.1.x dated 2002-07-04.

[root at cricket1 src]# diff ../../rrdtool-2002-07-04/src/rrd_tool.c
>       optind=0;
>       opterr=0;

Francois Mikus

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

More information about the rrd-users mailing list