[rrd-developers] Re: rrdtool segfault
Tobias Oetiker
oetiker at ee.ethz.ch
Tue Jan 13 22:52:30 MET 2004
Hi Matt,
gnu getopt is not useable for multithreaded applications due to its
use of globabl variables ...
not setting anything will help you here ... the only way out is to
replace gnu getopt with something less hacky ...
Peter Stamfest has written a patch for the developers version of
rrdtool which makes it threadsave. Check out:
http://www.ee.ethz.ch/~slist/rrd-developers/msg00988.html
this patch is in the devel codebase
tobi
Today Matt Scifo wrote:
> Hello
>
> I have a multi-threaded application, where each thread calls
> rrd_update(). At any given time, there are at least 125 threads running
> in parallel. Each thread is responsible for calling rrd_update() using
> the following code...
>
> update(string filename, string datasources, string values)
> {
> char *argv[6];
>
> // add -t argument to datasources
> datasources = "-t" + datasources;
>
> // RRD library call
> argv[0] = "update";
> argv[1] = (char *)filename.c_str();
> argv[2] = (char *)datasources.c_str();
> argv[3] = (char *)values.c_str();
> // Ex. argv = "update file.rrd -tDS1 N:U"
>
> optind = 0;
> opterr = 0;
> if (rrd_update(4, argv) == -1)
> results.push_back(rrd_get_error());
> else
> results.push_back("success");
> rrd_clear_error();
> }
>
> At random times, the application segfaults, always returning the same
> backtrace. Here is the gdb backtrace...
>
> #0 0x40101609 in confstr () from /lib/libc.so.6
> #1 0x4010237c in getopt_long () from /lib/libc.so.6
> #2 0x4002d2c4 in rrd_update () from /usr/lib/librrd.so.0
>
> I have read previous threads regarding the same problem, and they
> all indicate that it is necessary to clear the global vars optind
> and opterr before each call. As you can see above, I have done this,
> yet I am still receiving segfaults.
>
> I am running on RH8.0 with RRD 1.0.45.
>
> Can anyone provide any help?
>
> Thanks
>
> -Matt Scifo
>
> --
> 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
>
--
______ __ _
/_ __/_ / / (_) Oetiker @ ISG.EE, ETZ J97, ETH, CH-8092 Zurich
/ // _ \/ _ \/ / System Manager, Time Lord, Coder, Designer, Coach
/_/ \.__/_.__/_/ http://people.ee.ethz.ch/~oetiker +41(0)1-632-5286
--
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