Re: [xml] Global error (xmlLastError) not cleaned up if xmlCleanupParser() is called on a different thread!




On 10 Jun 2014, at 09:14, Daniel Veillard wrote:

* For this specific case (error cleanup), I strongly believe that the
problem could be corrected without affecting either the API or ABI, but I
don't have time to investigate more since the workaround `xmlResetLastError`
does work OK for me, as I only make libxml2 calls from C++ wrappers anyway.

Windows may have special ways to reclaim the memory, the problem is that
there is no safe way to do the cleanup in general. It's thread local
storage too, and then behaviour is OS dependent (possibly compiler
dependant). I take patches but it's a very difficult area....

FWIW last time this all came up (possibly my fault) I was going to send
you a patch,

What that would have done was:

a) provide 2 new calls:
   xmlContextPtr xmlNewContext()
   xmlFreerContext(xmlContextPtr ctx)

b) make these two increment a static variable, and if the variable was
zero on entry, do what xmlInitParser does; and decrement a static
variable, and if it reaches zero, do xmlCleanupParser. Make them return
and free an opaque xmlContext struct that currently holds nothing.

c) mark xmlInitParser and xmlCleanupParser as deprecated

This at least allows for multiple inits and frees between libraries,
but does not (yet) solve the problem of global variables. Eventually
we'd then make an xmlContext contain an xmlGlobalState and add
variants of each API call that allowed for an xmlContext to be
passed as the first argument; this could be relatively easily
done with some nasty perl on the source code.

-- 
Alex Bligh






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