[redland] Redland giving seg fault in a loop.

Dave Beckett dave.beckett at bristol.ac.uk
Mon Oct 29 10:22:04 GMT 2001


>>>abhinkar at yahoo.com said:
> Hi All:
> 
> I have a small routine which is giving me a seg fault. It gives me a
> seg fault as soon as I go into the loop the second time at line 8. Am
> I doing everything correctly? I could get rid of this problem by 
> calling the librdf_new_world() call outside the loop. But if I would
> like to do it "this" way why is that I get a seg. fault at the second
> time. Am I missing some initializations..?

This isn't a complete program, so I added a couple of headers to give:

----------------------------------------------------------------------
  1	#include <stdio.h>
  2	#include <librdf.h>
  3	
  4	void main() {
  5	  int  i;
  6	  librdf_world    *rlworld;
  7	  librdf_uri	*rluri;
  8	  for (i =0;i<100;i++) { 
  9	    rlworld = librdf_new_world();
 10	    if (rlworld!=NULL) {
 11	      librdf_world_open(rlworld);
 12	    } else {
 13	      return 1;
 14	      
 15	    }
 16	    rluri = librdf_new_uri(rlworld,"file:///some/uri");
 17	    librdf_free_uri(rlworld);
 18	    librdf_free_world(rlworld);
 19	    if (rlworld != NULL) {
 20	      rlworld = 0;
 21	    }
 22	  }
 23	}
----------------------------------------------------------------------


and compiled with gcc and got:

  2001-10-29-abhinkar.c:17: warning: passing arg 1 of `librdf_free_uri' from incompatible pointer type

so as Jan points out, changing line 17's rlworld to rluri will stop that.

However, I never tested running the one-time-only library
startup/shutdown code in a loop(!) and it doesn't seem to work.

For the moment, you will have to move the librdf_new_world,
librdf_free_world calls to somewhere that are called once only while
I investigate; but it looks like something at will take a little while.

Dave






More information about the redland-dev mailing list