On Tue, Jun 10, 2014 at 09:38:48AM +0100, Alex Bligh wrote: > > 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.
what happen is a sublibrary or a plugin uses libxml2 ? Then you crash the problem is that this assume a very controlled context and unfortunately that's not the case libxml2 is reused by a number of libraries. > 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. This would work if everybody started writing fresh code around libxml2, but that does not reflect reality unfortunately. Daniel -- Daniel Veillard | Open Source and Standards, Red Hat veill...@redhat.com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | virtualization library http://libvirt.org/ _______________________________________________ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org https://mail.gnome.org/mailman/listinfo/xml