Re: [xml] libxml and threads



May be there is a little misunderstanding here.
I said in my first email that it is entirely my fault the problem I am experiencing because I am new to the use of libxml2.
I did not say that libxml2 code leaks memory. I want to make clear again that its is my responsibility, not yours.

I can only say thanks for your suggestions. Unfortunately I did not find a detailed documentation on the web site. This is actually a pity since I firmly believe that libxml2 is a great achievement, but its complexity makes it difficult to use it correctly ( I have been developing unix apps for almost 20 years, including of course threaded apps, so I now exactly what kind of problems can occur).

Thanks again,
Massimo

On Feb 23, 2005, at 12:12 PM, Daniel Veillard wrote:

On Wed, Feb 23, 2005 at 11:55:41AM +0100, Massimo Cafaro wrote:
On Feb 23, 2005, at 11:38 AM, Daniel Veillard wrote:
Leak: 0x0110f690 size=48 string 'MUTX'
Call stack: [thread 280c000]: | 0x0 | _pthread_body |
thread_starter | provider_thr | grelc_get_sql |
xmlSAXParseMemoryWithData | xmlCreateMemoryParserCtxt |
xmlNewParserCtxt | xmlInitParserCtxt | xmlDefaultSAXHandlerInit |

__xmlDefaultSAXHandler | xmlGetGlobalState | xmlNewGlobalState |
xmlInitializeGlobalState | xmlInitGlobals | xmlNewMutex | malloc
|
malloc_zone_malloc


The threads code is the only one which can legally do direct
malloc()
without using xmlMalloc(), so it's among the memory use I won't
detect
leaks in regression tests.


I do not understand this. What is exactly what you call threads code?

code from libxml2 thread.c module.

The leaks originates in the xmlParseMemory() function, which is called

No. The leak originate when the application wide thread mutex is
allocated. The fact it comes from xmlParseMemory() is just that you did
not initialize the libxml2 module as explained
1/ in the docs
http://xmlsoft.org/threads.html
"call xmlInitParser() in the "main" thread before using any of the
libxml2 API (except possibly selecting a different memory allocator)"
obviously you are not doing this otherwise that mutex would
have been allocated by the time you call xmlParseMemory()
2/ in my previous mail

in my application many times in many threads. I do not know exactly how
do you check for leaks, I am using a standard tool on Mac OS X. May be
it is worth saying here that the leaks are exactly the same on linux,
as detected by valgrind.

Then your code is likely in error, very first thing is to follow the
documentation about thread safety ! Then come back with a complete
example reproducing the problem on Linux, not 3 lines out of context.

Daniel



--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



--

*************************************************************************************

Massimo Cafaro, Ph.D. Center for Advanced Computational Technologies
Assistant Professor Voice +39 0832 297371
University of Lecce, Italy Fax +39 0832 297279
Faculty of Engineering E-mail massimo cafaro unile it
Via per Monteroni cafaro cacr caltech edu
73100 Lecce, Italy Web http://sara.unile.it/~cafaro

*************************************************************************************

Attachment: PGP.sig
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]