Re: [xml] xmlCleanupParser() question / patch

On Tue, Jan 19, 2010 at 03:40:30PM +0100, Martin B. wrote:
Daniel Veillard wrote:
On Thu, Jan 14, 2010 at 02:59:50AM +0100, Aron Szabo wrote:

If I use the library in a threaded program and call
xmlCleanupParser() I can't reinitialize it.

So here's what happens:

1. xmlCleanupThreads() is called from xmlCleanupParser()
2. the global key is deleted by xmlCleanupParser() which was created
by xmlOnceInit()

 That makes sense. there is a big problem anyway with
xmlCleanupParser() most people seems to think it need to be used after
parsing while it's a library global operation and really should not
be called after parsing but only when the library is not in use anymore.

So overall I'm tempted to change xmlCleanupParser() to become an empty
routine, and rename the real function as xmlCleanupLibrary().
That way the various shared libraries deployed with that bug won't need
to be changed specifically, avoiding crashes when multiple libraries
using libxml2 are used. Then your patch should be applied to the new
xmlCleanupLibrary() function.

 Opinions ?

Makes sense. Though all people that use it correctly will have to
update their sources, which kind of seems unfair :-)

  Agreed, but the balance of damages is not the same, on one hand you
have a minimal one-time fixed size small leak, and on the other side
you get an ugly crash usually hard to debug because it becomes an
async error when using the library later.

Best thing would be if xmlCleanupParser() would be removed completely, no?

  That is impossible, for ABI compatibility,


Daniel Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library

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