Hi All,

I was tracking a memory leak and ended up with a very simple libxml
program that leaks according to valgrind (I reproduced it with libxml
2.6.26). 
Could someone, please, have a look at the attached c file and tell me if
I am doing something wrong? If not, I will create a bug report for it.
The valgrind report is also attached.

Thanks,
Christophe

-- 
Christophe Barbe - Software Engineer
Objective Systems, Inc.
REAL WORLD ASN.1 AND XML SOLUTIONS
Tel: +1 (484) 875-9841
Fax: +1 (484) 875-9830
Toll-free: (877) 307-6855 (USA only)
http://www.obj-sys.com
//#include <crtdbg.h>
#include <libxml/tree.h>

int main(void)
{
   xmlDocPtr doc;
   xmlNodePtr node0;
/*
   int LeakTmpFlag;
   _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
   _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
   _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
   _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
   _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
   _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
   LeakTmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
   LeakTmpFlag |= _CRTDBG_CHECK_ALWAYS_DF;
   LeakTmpFlag |= _CRTDBG_LEAK_CHECK_DF;
   LeakTmpFlag |= _CRTDBG_DELAY_FREE_MEM_DF;
   _CrtSetDbgFlag(LeakTmpFlag);
*/
   doc = xmlNewDoc("1.0");
   node0 = xmlNewNode(0, "P1");
   xmlDocSetRootElement(doc, node0);
   xmlSaveFormatFile("message.xml", doc, 1);
   xmlFreeDoc(doc);

}


==6293== Memcheck, a memory error detector.
==6293== Copyright (C) 2002-2005, and GNU GPL'd, by Julian Seward et al.
==6293== Using LibVEX rev 1471, a library for dynamic binary translation.
==6293== Copyright (C) 2004-2005, and GNU GPL'd, by OpenWorks LLP.
==6293== Using valgrind-3.1.0-Debian, a dynamic binary instrumentation 
framework.
==6293== Copyright (C) 2000-2005, and GNU GPL'd, by Julian Seward et al.
==6293== For more details, rerun with: -v
==6293== 
==6293== 
==6293== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 19 from 1)
==6293== malloc/free: in use at exit: 470 bytes in 19 blocks.
==6293== malloc/free: 30 allocs, 11 frees, 5,185 bytes allocated.
==6293== For counts of detected errors, rerun with: -v
==6293== searching for pointers to 19 not-freed blocks.
==6293== checked 121,364 bytes.
==6293== 
==6293== 48 bytes in 2 blocks are still reachable in loss record 1 of 4
==6293==    at 0x401C422: malloc (vg_replace_malloc.c:149)
==6293==    by 0x40B784E: xmlNewMutex (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x40B6A06: xmlInitGlobals (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x406727B: xmlInitParser (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x4115226: (within /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x4116921: xmlSaveFormatFileEnc (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x41169A4: xmlSaveFormatFile (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x8048568: main (in /home/christophe/data/tmp/libxml-leak/tester)
==6293== 
==6293== 
==6293== 62 bytes in 8 blocks are still reachable in loss record 2 of 4
==6293==    at 0x401C422: malloc (vg_replace_malloc.c:149)
==6293==    by 0x40B9FAF: xmlStrndup (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x40BA026: xmlStrdup (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x404E01B: xmlNewCharEncodingHandler (in 
/usr/lib/libxml2.so.2.6.24)
==6293==    by 0x404E134: xmlInitCharEncodingHandlers (in 
/usr/lib/libxml2.so.2.6.24)
==6293==    by 0x406728A: xmlInitParser (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x4115226: (within /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x4116921: xmlSaveFormatFileEnc (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x41169A4: xmlSaveFormatFile (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x8048568: main (in /home/christophe/data/tmp/libxml-leak/tester)
==6293== 
==6293== 
==6293== 160 bytes in 8 blocks are still reachable in loss record 3 of 4
==6293==    at 0x401C422: malloc (vg_replace_malloc.c:149)
==6293==    by 0x404E030: xmlNewCharEncodingHandler (in 
/usr/lib/libxml2.so.2.6.24)
==6293==    by 0x404E134: xmlInitCharEncodingHandlers (in 
/usr/lib/libxml2.so.2.6.24)
==6293==    by 0x406728A: xmlInitParser (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x4115226: (within /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x4116921: xmlSaveFormatFileEnc (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x41169A4: xmlSaveFormatFile (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x8048568: main (in /home/christophe/data/tmp/libxml-leak/tester)
==6293== 
==6293== 
==6293== 200 bytes in 1 blocks are still reachable in loss record 4 of 4
==6293==    at 0x401C422: malloc (vg_replace_malloc.c:149)
==6293==    by 0x404E0E6: xmlInitCharEncodingHandlers (in 
/usr/lib/libxml2.so.2.6.24)
==6293==    by 0x406728A: xmlInitParser (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x4115226: (within /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x4116921: xmlSaveFormatFileEnc (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x41169A4: xmlSaveFormatFile (in /usr/lib/libxml2.so.2.6.24)
==6293==    by 0x8048568: main (in /home/christophe/data/tmp/libxml-leak/tester)
==6293== 
==6293== LEAK SUMMARY:
==6293==    definitely lost: 0 bytes in 0 blocks.
==6293==      possibly lost: 0 bytes in 0 blocks.
==6293==    still reachable: 470 bytes in 19 blocks.
==6293==         suppressed: 0 bytes in 0 blocks.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to