List Info

Thread: Memory Leaks in parse3.c example




Memory Leaks in parse3.c example
user name
2006-08-08 13:04:20
All -

While working with parser3.c example 
(http://xmlsoft.o
rg/examples/parse3.c) on Solaris 8 Rational Purify 
identifies several areas as having leaked memory.

Modifying parse3.c to

while(1)
    example3Func(document, 6);

and closely monitoring the process using 'top' clearly
shows the process 
eating memory.

Any feedback on identified problem areas would be very
helpful.

..Chris

------ SNIPPETS FROM RATIONAL PURIFY ----------------

               main           [parse3.c:47]
                       * between the version it was compiled
for and the 
actual shared
                       * library used.
                       */
               =>     LIBXML_TEST_VERSION
                 
                      example3Func(document, 6);

               example3Func   [parse3.c:33]
                       * The document being in memory, it
have no base 
per RFC 2396,
                       * and the "noname.xml"
argument will serve as its 
base.
                       */
               =>     doc = xmlReadMemory(content,
length, "noname.xml", 
NULL, 0);
                      if (doc == NULL) {
                          fprintf(stderr, "Failed to
parse document\n");
                          return;
               main           [parse3.c:54]
                      /*
                       * Cleanup function for the XML
library.
                       */
               =>     xmlCleanupParser();
                      /*
                       * this is to debug memory for
regression tests
                       */
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Memory Leaks in parse3.c example
user name
2006-08-08 13:33:59
On Tue, Aug 08, 2006 at 09:04:20AM -0400, Chris Johnson
wrote:
> While working with parser3.c example 
> (http://xmlsoft.o
rg/examples/parse3.c) on Solaris 8 Rational Purify 
> identifies several areas as having leaked memory.
> 
> Modifying parse3.c to
> 
> while(1)
>     example3Func(document, 6);
> 
> and closely monitoring the process using 'top'
clearly shows the process 
> eating memory.
> 
> Any feedback on identified problem areas would be very
helpful.

  Sorry, no ... No leak seen here. Doing the same
modification and running in
loop for a while RSS stay at 600Kbytes used. There might be
a leak, but either
it's not in libxml2 or it's specific to your settup (which
would be quite
surprizing).
  Make sure you use the right latest libs etc... check stuff
at your OS level
and also possibly reconfigure to set up debugging as
exaplined in the doc:
   http://xmlso
ft.org/xmlmem.html#Debugging

Daniel

-- 
Daniel Veillard      | Red Hat http://redhat.com/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Memory Leaks in parse3.c example
user name
2006-08-09 11:20:14
Chris Johnson wrote:

> While working with parser3.c example 
> (http://xmlsoft.o
rg/examples/parse3.c) on Solaris 8 Rational Purify 
> identifies several areas as having leaked memory.

Normally Purify reports how many bytes have been leaked and
a stacktrace
of where the memory was allocated. I don't see either in
the output you
posted. Could you post the full output from Purify? (IIRC,
you can unset
the DISPLAY environment variable to get the output on the
console).
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Memory Leaks in parse3.c example
user name
2006-08-09 13:58:41
Bjorn Reese wrote:
> Chris Johnson wrote:
>
>> While working with parser3.c example 
>> (http://xmlsoft.o
rg/examples/parse3.c) on Solaris 8 Rational Purify 
>> identifies several areas as having leaked memory.
>
> Normally Purify reports how many bytes have been leaked
and a stacktrace
> of where the memory was allocated. I don't see either
in the output you
> posted. Could you post the full output from Purify?
(IIRC, you can unset
> the DISPLAY environment variable to get the output on
the console).

Bjorn -

Thanks for the reply.  I've done further testing and found
some very 
interesting results as follows.  It turns out when I compile
and link 
parse3.c with static version of libxml purify turns up
several memory 
leaks as shown in the attached a.out.static.  Thinking the
leaks are 
false positives I modified parse3.c to include a
"while(1)" around 
"example3Func()" it clearly leaks as shown using
top.

When compiling and linking parse3.c to use dynamic version
of libxml no 
leaks occur as illustrated in the attached a.out.dyn file. 
Again after 
modifying the parse3.c to confirm the findings from purify
to include 
the "while(1)" and examining the the process
using top it clearly is not 
leaking any memory.

Compile and Link line:

Static:

gcc -g -I/export/home/chris/dev/oem/include/libxml2
-L/usr/local/lib 
parse3.c  -lsocket -lnsl -lm -lz -liconv 
/export/home/chris/dev/oem/lib/libxml2.a


Dynamic:

gcc -g -I/export/home/chris/dev/oem/include/libxml2 
-L/export/home/chris/dev/oem/lib -L/usr/local/lib parse3.c 
-lxml2 
-lsocket -lnsl -lm -lz -liconv

OS: Solaris 8
gcc version: 3.4.2
libxml version : 2.6.26

Thanks
..Chris
****  Purify instrumented a.out (pid 18926 at Wed Aug  9
09:26:41 2006)
  * Purify 2003a.06.13 Solaris 2 (32-bit) (c) Copyright IBM
Corp. 1992, 2004 All rights reserved.  
  * For contact information type: "purify -help"
  * For Purify Viewer output, set the DISPLAY environment
variable.
  * Options settings: -purify \
    -purify-home=/usr/local/releases/purify.sol.2003a.06.13
\
    -gcc3_path=/usr/local/bin/gcc \
   
-cache-dir=/usr/local/releases/purify.sol.2003a.06.13/cache
\
    -demangle_program=/usr/local/bin/c++filt -threads=yes \
    -use-internal-locks=yes -thread_stack_change=0x4000
-mt_safe_malloc=yes 
  * License successfully checked out.

****  Purify instrumented a.out (pid 18926)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	check_nlspath_env [nlspath_checks.c]
	_init          [libc.so.1]
	call_init      [util.c]
	setup          [setup.c]
	_setup         [_setup.c]
	_rt_boot       []
  * Reading 4 bytes from 0xffbeecc0 on the stack.
  * Address 0xffbeecc0 is       16 bytes below frame pointer
in function check_nlspath_env.

****  Purify instrumented a.out (pid 18926)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	check_nlspath_env [nlspath_checks.c]
	_init          [libc.so.1]
	call_init      [util.c]
	setup          [setup.c]
	_setup         [_setup.c]
	_rt_boot       []
  * Reading 4 bytes from 0xffbeecc4 on the stack.
  * Address 0xffbeecc4 is       12 bytes below frame pointer
in function check_nlspath_env.

****  Purify instrumented a.out (pid 18926)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	check_nlspath_env [nlspath_checks.c]
	_init          [libc.so.1]
	call_init      [util.c]
	setup          [setup.c]
	_setup         [_setup.c]
	_rt_boot       []
  * Reading 4 bytes from 0xffbeecc8 on the stack.
  * Address 0xffbeecc8 is        8 bytes below frame pointer
in function check_nlspath_env.

****  Purify instrumented a.out (pid 18926)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	check_nlspath_env [nlspath_checks.c]
	_init          [libc.so.1]
	call_init      [util.c]
	setup          [setup.c]
	_setup         [_setup.c]
	_rt_boot       []
  * Reading 4 bytes from 0xffbeeccc on the stack.
  * Address 0xffbeeccc is        4 bytes below frame pointer
in function check_nlspath_env.
  * Command-line: ./a.out 

****  Purify instrumented a.out (pid 18926)  ****
Current file descriptors in use: 5
FIU: file descriptor 0: <stdin>
FIU: file descriptor 1: <stdout>
FIU: file descriptor 2: <stderr>
FIU: file descriptor 26: <reserved for Purify internal
use>
FIU: file descriptor 27: <reserved for Purify internal
use>

****  Purify instrumented a.out (pid 18926)  ****
Purify: Searching for all memory leaks...

Memory leaked: 0 bytes (0%); potentially leaked: 0 bytes
(0%)

Purify Heap Analysis (combining suppressed and unsuppressed
blocks)
                         Blocks        Bytes
              Leaked          0            0
  Potentially Leaked          0            0
              In-Use          1            4
  ----------------------------------------
     Total Allocated          1            4

****  Purify instrumented a.out (pid 18926)  ****
Thread Summary : 7 threads in existence
  * Thread 0 [main thread]
     Stack Limit : (0xff3f0000 0xffbf0000), size = 0x800000
  * Thread 1
     Stack Limit : (0xfe310000 0xfe410000), size = 0x100000

     Stack Use : (0xfe40fa30 0xfe40fd54), size = 0x324
  * Thread 2
     Stack Limit : (0xfd8f2000 0xfd8f6000), size = 0x4000

     Stack Use : (0xfd8f5978 0xfd8f5d54), size = 0x3dc
  * Thread 3
     Stack Limit : (0xfec4da14 0xfec692a8), size = 0x1b894

     Stack Use : (0xfec52700 0xfec527a4), size = 0xa4
  * Thread 4
     Stack Limit : (0xfe20e000 0xfe30e000), size = 0x100000

     Stack Use : (0xfe30db18 0xfe30dd54), size = 0x23c
  * Thread 5
     Stack Limit : (0xfd872000 0xfd874000), size = 0x2000

     Stack Use : (0xfd873b28 0xfd873d54), size = 0x22c
  * Thread 6
     Stack Limit : (0xfd862000 0xfd866000), size = 0x4000

     Stack Use : (0xfd865b28 0xfd865d54), size = 0x22c

****  Purify instrumented a.out (pid 18926)  ****
  * Program exited with status code 0.
  * 4 access errors, 4 total occurrences.
  * 0 bytes leaked.
  * 0 bytes potentially leaked.
  * Basic memory usage (including Purify overhead):
    377068 code
    115548 data/bss
    25240 heap (peak use)
    4048 stack
  * Shared library memory usage (including Purify overhead):
    992 libpure_solaris2_init.so.1 (shared code)
    280 libpure_solaris2_init.so.1 (private data)
    1846968 libxml2.so.2_pure_p3_c0_108201622_58_32 (shared
code)
    48884 libxml2.so.2_pure_p3_c0_108201622_58_32 (private
data)
    57676 libsocket.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    4984 libsocket.so.1_pure_p3_c0_108201622_58_32 (private
data)
    1031864 libnsl.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    67752 libnsl.so.1_pure_p3_c0_108201622_58_32 (private
data)
    127772 libm.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    1236 libm.so.1_pure_p3_c0_108201622_58_32 (private data)
    87996 libz.so.1_pure_p3_c0_108201622_58_32 (shared code)
    6316 libz.so.1_pure_p3_c0_108201622_58_32 (private data)
    916888 libiconv.so.2_pure_p3_c0_108201622_58_32 (shared
code)
    24852 libiconv.so.2_pure_p3_c0_108201622_58_32 (private
data)
    1106340 libc.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    31276 libc.so.1_pure_p3_c0_108201622_58_32 (private
data)
    2512 libdl.so.1_pure_p3_c0_108201622_58_32 (shared code)
    76 libdl.so.1_pure_p3_c0_108201622_58_32 (private data)
    15416 libinternal_stubs.so.1 (shared code)
    1044 libinternal_stubs.so.1 (private data)
    17452 libpthread.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    288 libpthread.so.1_pure_p3_c0_108201622_58_32 (private
data)
    49048 libgcc_s.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    2396 libgcc_s.so.1_pure_p3_c0_108201622_58_32 (private
data)
    16552 libmp.so.2_pure_p3_c0_108201622_58_32 (shared
code)
    892 libmp.so.2_pure_p3_c0_108201622_58_32 (private data)
    4500 libdoor.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    572 libdoor.so.1_pure_p3_c0_108201622_58_32 (private
data)
    14084 libc_psr.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    76 libc_psr.so.1_pure_p3_c0_108201622_58_32 (private
data)
    179976 libthread.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    119464 libthread.so.1_pure_p3_c0_108201622_58_32
(private data)
  * Memory mapped usage:
    1048576 mmap'd at 0xfdc02000
    1048576 mmap'd at 0xfdd04000
    1048576 mmap'd at 0xfde06000
    1048576 mmap'd at 0xfdf08000
    1048576 mmap'd at 0xfe00a000
    1048576 mmap'd at 0xfe10c000
    1048576 mmap'd at 0xfe20e000
    1048576 mmap'd at 0xfe310000
    16384 mmap'd at 0xfd862000
    8192 mmap'd at 0xfd872000
    16384 mmap'd at 0xfd8f2000
    8192 mmap'd PROT_NONE at 0xfdc00000
    8192 mmap'd PROT_NONE at 0xfd860000
    8192 mmap'd PROT_NONE at 0xfd870000
    8192 mmap'd PROT_NONE at 0xfd8f0000
    8192 mmap'd PROT_NONE at 0xfe30e000
    8192 mmap'd PROT_NONE at 0xfe20c000
    8192 mmap'd PROT_NONE at 0xfe10a000
    8192 mmap'd PROT_NONE at 0xfe008000
    8192 mmap'd PROT_NONE at 0xfdf06000
    8192 mmap'd PROT_NONE at 0xfde04000
    8192 mmap'd PROT_NONE at 0xfdd02000

****  Purify instrumented a.out (pid 18949 at Wed Aug  9
09:28:25 2006)
  * Purify 2003a.06.13 Solaris 2 (32-bit) (c) Copyright IBM
Corp. 1992, 2004 All rights reserved.  
  * For contact information type: "purify -help"
  * For Purify Viewer output, set the DISPLAY environment
variable.
  * Options settings: -purify \
    -purify-home=/usr/local/releases/purify.sol.2003a.06.13
\
    -gcc3_path=/usr/local/bin/gcc \
   
-cache-dir=/usr/local/releases/purify.sol.2003a.06.13/cache
\
    -demangle_program=/usr/local/bin/c++filt 
  * License successfully checked out.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	check_nlspath_env [nlspath_checks.c]
	_init          [libc.so.1]
	call_init      [util.c]
	setup          [setup.c]
	_setup         [_setup.c]
	_rt_boot       []
  * Reading 4 bytes from 0xffbeecc0 on the stack.
  * Address 0xffbeecc0 is       16 bytes below frame pointer
in function check_nlspath_env.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	check_nlspath_env [nlspath_checks.c]
	_init          [libc.so.1]
	call_init      [util.c]
	setup          [setup.c]
	_setup         [_setup.c]
	_rt_boot       []
  * Reading 4 bytes from 0xffbeecc4 on the stack.
  * Address 0xffbeecc4 is       12 bytes below frame pointer
in function check_nlspath_env.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	check_nlspath_env [nlspath_checks.c]
	_init          [libc.so.1]
	call_init      [util.c]
	setup          [setup.c]
	_setup         [_setup.c]
	_rt_boot       []
  * Reading 4 bytes from 0xffbeecc8 on the stack.
  * Address 0xffbeecc8 is        8 bytes below frame pointer
in function check_nlspath_env.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	check_nlspath_env [nlspath_checks.c]
	_init          [libc.so.1]
	call_init      [util.c]
	setup          [setup.c]
	_setup         [_setup.c]
	_rt_boot       []
  * Reading 4 bytes from 0xffbeeccc on the stack.
  * Address 0xffbeeccc is        4 bytes below frame pointer
in function check_nlspath_env.
  * Command-line: ./a.out 

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlGenericError [globals.c:857]
	xmlInitParser  [parser.c:12737]
	xmlCheckVersion [parserInternals.c:73]
	main           [parse3.c:47]
  * Reading 4 bytes from 0xffbeedfc on the stack.
  * Address 0xffbeedfc is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlGenericError [globals.c:857]
	initGenericErrorDefaultFunc [error.c:93]
	xmlInitParser  [parser.c:12739]
	xmlCheckVersion [parserInternals.c:73]
  * Reading 4 bytes from 0xffbeed8c on the stack.
  * Address 0xffbeed8c is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlDefaultSAXHandler [globals.c:821]
	xmlDefaultSAXHandlerInit [SAX2.c:2770]
	xmlInitParser  [parser.c:12744]
	xmlCheckVersion [parserInternals.c:73]
  * Reading 4 bytes from 0xffbeed8c on the stack.
  * Address 0xffbeed8c is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__htmlDefaultSAXHandler [globals.c:699]
	htmlDefaultSAXHandlerInit [SAX2.c:2827]
	xmlInitParser  [parser.c:12751]
	xmlCheckVersion [parserInternals.c:73]
  * Reading 4 bytes from 0xffbeed8c on the stack.
  * Address 0xffbeed8c is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlDefaultSAXHandler [globals.c:821]
	xmlDefaultSAXHandlerInit [SAX2.c:2770]
	xmlInitParserCtxt [parserInternals.c:1513]
	xmlNewParserCtxt [parserInternals.c:1767]
  * Reading 4 bytes from 0xffbeec34 on the stack.
  * Address 0xffbeec34 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlLoadExtDtdDefaultValue [globals.c:969]
	xmlInitParserCtxt [parserInternals.c:1631]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]
  * Reading 4 bytes from 0xffbeeca4 on the stack.
  * Address 0xffbeeca4 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlDoValidityCheckingDefaultValue [globals.c:840]
	xmlInitParserCtxt [parserInternals.c:1632]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]
  * Reading 4 bytes from 0xffbeeca4 on the stack.
  * Address 0xffbeeca4 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlPedanticParserDefaultValue [globals.c:1012]
	xmlInitParserCtxt [parserInternals.c:1633]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]
  * Reading 4 bytes from 0xffbeeca4 on the stack.
  * Address 0xffbeeca4 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlLineNumbersDefaultValue [globals.c:952]
	xmlInitParserCtxt [parserInternals.c:1634]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]
  * Reading 4 bytes from 0xffbeeca4 on the stack.
  * Address 0xffbeeca4 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlKeepBlanksDefaultValue [globals.c:935]
	xmlInitParserCtxt [parserInternals.c:1635]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]
  * Reading 4 bytes from 0xffbeeca4 on the stack.
  * Address 0xffbeeca4 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlSubstituteEntitiesDefaultValue [globals.c:1046]
	xmlInitParserCtxt [parserInternals.c:1650]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]
  * Reading 4 bytes from 0xffbeeca4 on the stack.
  * Address 0xffbeeca4 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlDefaultBufferSize [globals.c:803]
	xmlAllocParserInputBuffer [xmlIO.c:2126]
	xmlParserInputBufferCreateMem [xmlIO.c:2621]
	xmlCreateMemoryParserCtxt [parser.c:12415]
  * Reading 4 bytes from 0xffbeeca4 on the stack.
  * Address 0xffbeeca4 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlBufferAllocScheme [globals.c:786]
	xmlBufferCreateSize [tree.c:6546]
	xmlAllocParserInputBuffer [xmlIO.c:2126]
	xmlParserInputBufferCreateMem [xmlIO.c:2621]
  * Reading 4 bytes from 0xffbeec34 on the stack.
  * Address 0xffbeec34 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlDefaultSAXLocator [globals.c:831]
	xmlParseDocument [parser.c:9061]
	xmlDoRead      [parser.c:13140]
	example3Func   [parse3.c:33]
  * Reading 4 bytes from 0xffbeed7c on the stack.
  * Address 0xffbeed7c is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlDefaultSAXHandler [globals.c:821]
	xmlFreeParserCtxt [parserInternals.c:1690]
	xmlDoRead      [parser.c:13151]
	example3Func   [parse3.c:33]
  * Reading 4 bytes from 0xffbeed84 on the stack.
  * Address 0xffbeed84 is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	_libc_pthread_getspecific [libc.so.1]
	xmlGetGlobalState [threads.c:533]
	__xmlLastError [globals.c:709]
	xmlResetLastError [error.c:891]
	xmlCleanupParser [parser.c:12789]
	main           [parse3.c:54]
  * Reading 4 bytes from 0xffbeedfc on the stack.
  * Address 0xffbeedfc is        4 bytes below frame pointer
in function _libc_pthread_getspecific.

****  Purify instrumented a.out (pid 18949)  ****
Current file descriptors in use: 5
FIU: file descriptor 0: <stdin>
FIU: file descriptor 1: <stdout>
FIU: file descriptor 2: <stderr>
FIU: file descriptor 26: <reserved for Purify internal
use>
FIU: file descriptor 27: <reserved for Purify internal
use>

****  Purify instrumented a.out (pid 18949)  ****
Purify: Searching for all memory leaks...

Memory leaked: 8216 bytes (99.7%); potentially leaked: 0
bytes (0%)

MLK: 512 bytes leaked at 0x225f38
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlGenericError [globals.c:857]
	xmlInitParser  [parser.c:12737]
	xmlCheckVersion [parserInternals.c:73]
	main           [parse3.c:47]

MLK: 512 bytes leaked at 0x226200
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlGenericError [globals.c:857]
	initGenericErrorDefaultFunc [error.c:93]
	xmlInitParser  [parser.c:12739]
	xmlCheckVersion [parserInternals.c:73]

MLK: 512 bytes leaked at 0x226c98
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlDefaultSAXHandler [globals.c:821]
	xmlDefaultSAXHandlerInit [SAX2.c:2770]
	xmlInitParser  [parser.c:12744]
	xmlCheckVersion [parserInternals.c:73]

MLK: 512 bytes leaked at 0x226ef0
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__htmlDefaultSAXHandler [globals.c:699]
	htmlDefaultSAXHandlerInit [SAX2.c:2827]
	xmlInitParser  [parser.c:12751]
	xmlCheckVersion [parserInternals.c:73]

MLK: 512 bytes leaked at 0x227358
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlDefaultSAXHandler [globals.c:821]
	xmlDefaultSAXHandlerInit [SAX2.c:2770]
	xmlInitParserCtxt [parserInternals.c:1513]
	xmlNewParserCtxt [parserInternals.c:1767]

MLK: 512 bytes leaked at 0x228280
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlLoadExtDtdDefaultValue [globals.c:969]
	xmlInitParserCtxt [parserInternals.c:1631]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]

MLK: 512 bytes leaked at 0x2284d8
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlDoValidityCheckingDefaultValue [globals.c:840]
	xmlInitParserCtxt [parserInternals.c:1632]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]

MLK: 512 bytes leaked at 0x228730
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlPedanticParserDefaultValue [globals.c:1012]
	xmlInitParserCtxt [parserInternals.c:1633]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]

MLK: 512 bytes leaked at 0x228988
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlLineNumbersDefaultValue [globals.c:952]
	xmlInitParserCtxt [parserInternals.c:1634]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]

MLK: 512 bytes leaked at 0x228be0
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlKeepBlanksDefaultValue [globals.c:935]
	xmlInitParserCtxt [parserInternals.c:1635]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]

MLK: 512 bytes leaked at 0x228e38
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlSubstituteEntitiesDefaultValue [globals.c:1046]
	xmlInitParserCtxt [parserInternals.c:1650]
	xmlNewParserCtxt [parserInternals.c:1767]
	xmlCreateMemoryParserCtxt [parser.c:12410]

MLK: 512 bytes leaked at 0x229108
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlDefaultBufferSize [globals.c:803]
	xmlAllocParserInputBuffer [xmlIO.c:2126]
	xmlParserInputBufferCreateMem [xmlIO.c:2621]
	xmlCreateMemoryParserCtxt [parser.c:12415]

MLK: 512 bytes leaked at 0x2293c8
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlBufferAllocScheme [globals.c:786]
	xmlBufferCreateSize [tree.c:6546]
	xmlAllocParserInputBuffer [xmlIO.c:2126]
	xmlParserInputBufferCreateMem [xmlIO.c:2621]

MLK: 512 bytes leaked at 0x22bc28
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlDefaultSAXLocator [globals.c:831]
	xmlParseDocument [parser.c:9061]
	xmlDoRead      [parser.c:13140]
	example3Func   [parse3.c:33]

MLK: 512 bytes leaked at 0x22c210
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlDefaultSAXHandler [globals.c:821]
	xmlFreeParserCtxt [parserInternals.c:1690]
	xmlDoRead      [parser.c:13151]
	example3Func   [parse3.c:33]

MLK: 512 bytes leaked at 0x22c468
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlGetGlobalState [threads.c:455]
	__xmlLastError [globals.c:709]
	xmlResetLastError [error.c:891]
	xmlCleanupParser [parser.c:12789]
	main           [parse3.c:54]

MLK: 24 bytes leaked at 0x226190
  * This memory was allocated from:
	malloc         [rtlib.o]
	xmlNewMutex    [threads.c:180]
	xmlInitGlobals [globals.c:49]
	xmlInitializeGlobalState [globals.c:495]
	xmlGetGlobalState [threads.c:460]
	__xmlGenericError [globals.c:857]

Purify Heap Analysis (combining suppressed and unsuppressed
blocks)
                         Blocks        Bytes
              Leaked         17         8216
  Potentially Leaked          0            0
              In-Use          1           24
  ----------------------------------------
     Total Allocated         18         8240

****  Purify instrumented a.out (pid 18949)  ****
  * Program exited with status code 0.
  * 20 access errors, 20 total occurrences.
  * 8216 bytes leaked.
  * 0 bytes potentially leaked.
  * Basic memory usage (including Purify overhead):
    1981956 code
    139516 data/bss
    32768 heap (peak use)
    4048 stack
  * Shared library memory usage (including Purify overhead):
    992 libpure_solaris2_init.so.1 (shared code)
    280 libpure_solaris2_init.so.1 (private data)
    57676 libsocket.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    4984 libsocket.so.1_pure_p3_c0_108201622_58_32 (private
data)
    1031864 libnsl.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    67752 libnsl.so.1_pure_p3_c0_108201622_58_32 (private
data)
    127772 libm.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    1236 libm.so.1_pure_p3_c0_108201622_58_32 (private data)
    87996 libz.so.1_pure_p3_c0_108201622_58_32 (shared code)
    6316 libz.so.1_pure_p3_c0_108201622_58_32 (private data)
    916888 libiconv.so.2_pure_p3_c0_108201622_58_32 (shared
code)
    24852 libiconv.so.2_pure_p3_c0_108201622_58_32 (private
data)
    1106340 libc.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    31276 libc.so.1_pure_p3_c0_108201622_58_32 (private
data)
    2512 libdl.so.1_pure_p3_c0_108201622_58_32 (shared code)
    76 libdl.so.1_pure_p3_c0_108201622_58_32 (private data)
    15416 libinternal_stubs.so.1 (shared code)
    1044 libinternal_stubs.so.1 (private data)
    16552 libmp.so.2_pure_p3_c0_108201622_58_32 (shared
code)
    892 libmp.so.2_pure_p3_c0_108201622_58_32 (private data)
    4500 libdoor.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    572 libdoor.so.1_pure_p3_c0_108201622_58_32 (private
data)
    14084 libc_psr.so.1_pure_p3_c0_108201622_58_32 (shared
code)
    76 libc_psr.so.1_pure_p3_c0_108201622_58_32 (private
data)

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Memory Leaks in parse3.c example
user name
2006-08-10 16:02:58
Chris Johnson wrote:

> Thanks for the reply.  I've done further testing and
found some very 
> interesting results as follows.  It turns out when I
compile and link 
> parse3.c with static version of libxml purify turns up
several memory 
> leaks as shown in the attached a.out.static.  Thinking
the leaks are 

I do not know why it behave differently in the static and
shared
versions, so I will concentrate on the static version that
has the
leaks. Furthermore, I do not have access to a Solaris
machine at the
moment, so the following is deduced from reading the source
code.

It appears that xmlNewGlobalState() is called many times
instead of just
once. Can you confirm this? (this is probably easiest done
by putting a
breakpoint in the function).

If so, then the problem may be related to the initialization
of the
globalvar variable. What is the return value of
phread_once() in
xmlGetGlobalState()? Is xmlOnceInit() called, and what is
the return
value of pthread_key_create()?
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Memory Leaks in parse3.c example
user name
2006-08-10 18:54:41
Bjorn Reese wrote:
> Chris Johnson wrote:
>
>> Thanks for the reply.  I've done further testing
and found some very 
>> interesting results as follows.  It turns out when
I compile and link 
>> parse3.c with static version of libxml purify turns
up several memory 
>> leaks as shown in the attached a.out.static. 
Thinking the leaks are 
>
> I do not know why it behave differently in the static
and shared
> versions, so I will concentrate on the static version
that has the
> leaks. Furthermore, I do not have access to a Solaris
machine at the
> moment, so the following is deduced from reading the
source code.
>
> It appears that xmlNewGlobalState() is called many
times instead of just
> once. Can you confirm this? (this is probably easiest
done by putting a
> breakpoint in the function).
>
> If so, then the problem may be related to the
initialization of the
> globalvar variable. What is the return value of
phread_once() in
> xmlGetGlobalState()? Is xmlOnceInit() called, and what
is the return
> value of pthread_key_create()?

xmlNewGlobalState() is not available to break in but
xmlGetGlobalState() 
is called about 16times.
phread_once()'s return value is never checked within the
existing 
codebase but... phread_once() returns 0 all 16times.
xmlOnceInit() is never called therefore pthread_key_create
is never 
called from xmlOnceInit().

You may also want to note this is on a Solaris 8 SPARC box.

Hope this helps
..Chris

_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Memory Leaks in parse3.c example
user name
2006-08-11 09:23:16
Chris Johnson wrote:

> xmlNewGlobalState() is not available to break in

It has probably been inlined by the compiler.

> xmlOnceInit() is never called therefore
pthread_key_create is never 
> called from xmlOnceInit().

I believe that we have found the problem. According to the
following
URL you should link with -lpthread.

http://groups.google.dk/group/comp.pr
ogramming.threads/msg/ac097ead118c41a6

Does 'xml2-config --libs' include -lpthread or not?
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Memory Leaks in parse3.c example
user name
2006-08-11 11:38:22
Bjorn Reese wrote:
> Chris Johnson wrote:
>
>> xmlNewGlobalState() is not available to break in
>
> It has probably been inlined by the compiler.
>
>> xmlOnceInit() is never called therefore
pthread_key_create is never 
>> called from xmlOnceInit().
>
> I believe that we have found the problem. According to
the following
> URL you should link with -lpthread.
>
> http://groups.google.dk/group/comp.pr
ogramming.threads/msg/ac097ead118c41a6 
>
>
> Does 'xml2-config --libs' include -lpthread or not?
$ xml2-config --libs
-L/tmp/lib -R/tmp/lib -lxml2 -lz -lpthread -liconv -lm
-lsocket -lnsl

As it turns out if I link parse3.c with -lpthread the
problem goes 
away.. so my new compile and link line looks something like

gcc -g -I/export/home/chris/dev/oem/include/libxml2
-L/usr/local/lib 
parse3.c  -lpthread -lsocket -lnsl -lm -lz -liconv 
/export/home/chris/dev/oem/lib/libxml2.a

Should I have to use -lpthread while linking parse3.c?

Thanks for all your help
..Chris
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
Memory Leaks in parse3.c example
user name
2006-08-11 12:41:24
On Fri, Aug 11, 2006 at 07:38:22AM -0400, Chris Johnson
wrote:
> Bjorn Reese wrote:
> > Chris Johnson wrote:
> >
> >> xmlNewGlobalState() is not available to break
in
> >
> > It has probably been inlined by the compiler.
> >
> >> xmlOnceInit() is never called therefore
pthread_key_create is never 
> >> called from xmlOnceInit().
> >
> > I believe that we have found the problem.
According to the following
> > URL you should link with -lpthread.
> >
> > http://groups.google.dk/group/comp.pr
ogramming.threads/msg/ac097ead118c41a6 
> >
> >
> > Does 'xml2-config --libs' include -lpthread or
not?
> $ xml2-config --libs
> -L/tmp/lib -R/tmp/lib -lxml2 -lz -lpthread -liconv -lm
-lsocket -lnsl
> 
> As it turns out if I link parse3.c with -lpthread the
problem goes 
> away.. so my new compile and link line looks something
like
> 
> gcc -g -I/export/home/chris/dev/oem/include/libxml2
-L/usr/local/lib 
> parse3.c  -lpthread -lsocket -lnsl -lm -lz -liconv 
> /export/home/chris/dev/oem/lib/libxml2.a
> 
> Should I have to use -lpthread while linking parse3.c?

  <sigh/>

  http://xmlsoft.
org/FAQ.html#Developer

 use xml2-config --cflags and xml2-config --libs as
suggested.

Daniel

-- 
Red Hat Virtualization group http://redhat.com/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-9]

about | contact  Other archives ( Real Estate discussion Medical topics )