[redland-dev] My code causes infinite loop

Dave Beckett dave at dajobe.org
Fri Aug 22 00:43:39 EDT 2014


On 8/15/14, 2:17 PM, Victor Porton wrote:
> My testing code for Ada bindings of Raptor at https://github.com/vporton/redland-bindings/tree/ada2012 (the script run_all_tests) causes an infinite loop.
> 
> When run under GDB it instead of infinite loop:
> 
> Program received signal SIGSEGV, Segmentation fault.
> malloc_consolidate (av=0xf7b43420 <main_arena>) at malloc.c:4151
> 4151    malloc.c: No such file or directory.
> 
> The particular Ada line which causes the infinite loop:
> 
> Assert(To_String(Datatype(Get_Literal(Term_1))) = "http://example.org", "Term_1 datatype");
> 
> My question: May this error be caused by an object not deallocated before finalizing "world" object?
> 
> In other words: If an object is not deallocated, is it just memory leak, or may it lead for more serious errors?

I don't know the answer to the specific error here but you have to take
care that you are respecting the allocation model.

If a function returns a shared string (char*), the caller needs to copy it
in order to preserve it.  Similarly (but much rarer) an input char*
may become owned by a raptor object and so the caller should not deallocate
it but I don't think happens too often in raptor

I often run the C tests under valgrind and other dynamic and static checkers
to ensure all memory and resources are returned on all error paths.

Dave



More information about the redland-dev mailing list