[rrd-users] Segmentation fault using devel version

Rene Gallati security at draxinusom.ch
Mon Jan 3 14:47:06 MET 2005


Hi List,

I'm trying to use rrdtool as library for my C-project. Unfortunately, 
I've came across a bug in the rrdtool-devel branch.

In short, the equivalent of "rrdtool create" simply does not work 
(anymore?). It crashes with segmentation fault immediately.

Use the following code to replicate:

************* rrdtest.c ******************
#include "rrd.h"

void test_create () {
	char *r_create[7] = {"create", "/tmp/test.rrd",
			"--step", "60", "DS:minmax:COUNTER:120:0:U",
			"RRA:MAX:0:1:320", "RRA:LAST:0.5:1:30240"};
					
	printf("doit\n");
	int retval = rrd_create(7, r_create);
	printf("retval = %i\n", retval);
	if(rrd_test_error()) {
		printf("error from rrd=%s\n", rrd_get_error());
		rrd_clear_error();
	}
}

int main (int argc, char *argv[])
{
	test_create();
	return 0;
}
*************

compiled with:
*******
gcc -Wall -O0 -g -I./include -L/usr/local/rrdtool-1.1.0/lib -lrrd 
src/rrdtest.c -o ./bin/test2
*******
running gives:

*******
$bin/test2
doit
Segmentation fault
*******

I've tested using the rrdtool snapshots from 18.11.2004, 31.12.2004 and 
todays snapshot (03.01.2005) - all show the same behaviour.

Giving the parameters on the commandline to the rrdtool binary works as 
expected. If I remove the somewhat superflous "create" string and 
decrement the ints, nothing changes (btw: is there ANY documentation 
about using rrdtool as library? I've never seen anything wheter you 
should say create or not as first parameter even though the method name 
says it anyway)

If I call
*******
    int retval = rrd_create(5, r_create);
*******
ie, without the RRA's, then I get the correct answer:

*******
doit
retval = -1
error from rrd=you must define at least one Round Robin Archive
*******

I've taken care that the correct version of the library is used (double 
checked, adapted LD_LIBRARY_PATH, etc. like the "make install" process 
says) but to no avail.

create simply does not work when trying to use rrdtool as a library.

If I change the code to not use create, but dump an already existing rrd 
database like so:

*******
	char *r_create[2] = {"info", "/usr/src/da/proto/test.rrd"};
			
	printf("doit\n");
	int retval = rrd_dump(2, r_create);
*******

It works and I get:

*******
doit
<!-- Round Robin Database Dump -->
<rrd>
         <version> 0003 </version>
         <step> 3600 </step> <!-- Seconds -->

... lots of XML deleted
             </database>
         </rra>
</rrd>
retval = 0
*******

So finally the question: Am I doing something wrong (I also tried 
getting a context and calling the _r threadsafe variant with the same 
result) or is this a bug in rrdtool?

I've tried the same code with the stable version and it works fine 
there. Unfortunately, I need the HW-prediction so I need the devel branch.

Any hints much appreciated.

Oh and one last minor thing: how do I do a "rrdtool info" equivalent ? 
There seems to be a missing declaration in rrd.h

Thanks for any advice


-- 

C U

      - -- ---- ----- -----/\/  René Gallati  \/\---- ----- --- -- -

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