[redland-dev] raptor: possible memory leak when an element is not closed properly

Mark Smith mcs at umich.edu
Fri May 21 20:11:07 BST 2004


I am experimenting with Raptor on Linux (RH 9.0+).  Valgrind reports a 
memory leak for RDFXML documents that contain elements that are no 
closed properly.  Here is an example:

<r:RDF
        xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:dc="http://purl.org/dc/elements/1.0/">
        <r:Description>
                <dc:subject>bookmark</dc:subject>
                <dc:language>en</dc:languagXXXXXXe>
        </r:Description>
</r:RDF>

Save the above as /tmp/invalid.xml and execute this command to see the leak:

valgrind --num-callers=25 --leak-check=yes ./rapper -i rdfxml 
/tmp/invalid.xml

Here is the relevant portion of the valgrind output:

==4162== 40 bytes in 1 blocks are definitely lost in loss record 3 of 6
==4162==    at 0x40029B2A: calloc (vg_replace_malloc.c:284)
==4162==    by 0x40234DE2: raptor_new_sax2_element (raptor_sax2.c:86)
==4162==    by 0x402279B4: raptor_xml_start_element_handler 
(raptor_parse.c:798)
==4162==    by 0x4024AE80: (within /usr/lib/libexpat.so.0.4.0)
==4162==    by 0x4024A72A: (within /usr/lib/libexpat.so.0.4.0)
==4162==    by 0x4024D29D: (within /usr/lib/libexpat.so.0.4.0)
==4162==    by 0x4024D0B0: (within /usr/lib/libexpat.so.0.4.0)
==4162==    by 0x4024A1BA: XML_ParseBuffer (in /usr/lib/libexpat.so.0.4.0)
==4162==    by 0x4024A14C: XML_Parse (in /usr/lib/libexpat.so.0.4.0)
==4162==    by 0x40228A3A: raptor_xml_parse_chunk_ (raptor_parse.c:1489)
==4162==    by 0x40228A9D: raptor_xml_parse_chunk (raptor_parse.c:1561)
==4162==    by 0x40230288: raptor_parse_chunk (raptor_general.c:452)
==4162==    by 0x40230423: raptor_parse_file_stream (raptor_general.c:517)
==4162==    by 0x4023055F: raptor_parse_file (raptor_general.c:566)
==4162==    by 0x8049C4E: main (rdfdump.c:521)
==4162==    by 0x4027C8C6: __libc_start_main (in /lib/libc-2.3.2.so)

I am not familiar enough with the raptor code to propose a fix, but it 
seems like some change needs to be made to raptor_free_parser() to clean 
up the sax2_elements.

-- 
Mark Smith
LDAP Book Information: http://www.ldapbook.com/
What's Next:           http://www.pearlcrescent.com/






More information about the redland-dev mailing list