Heads-Up: Beware of xmlCleanupParser() when your package links against libxml2

Daniel Veillard veillard at redhat.com
Wed Jan 13 15:00:48 UTC 2010


On Wed, Jan 13, 2010 at 02:19:16AM +0100, Haïkel Guémar wrote:
> Le 13/01/2010 02:07, Tom Lane a écrit :
> > 
> > Why exactly is this a misuse, and not libxml2's bug to fix?  There's
> > certainly nothing in their documentation suggesting that there's
> > such a requirement.

  there is definitely,
  http://xmlsoft.org/html/libxml-parser.html#xmlCleanupParser

> 
> Afaik it does, i agree with Lennart that a warning from libxml2 would be
> welcome.

  The problem is that you can perfectly have application not relying on
libxml2 outside of their own code use libxml2 at different phases,
for example when parsing input, and when generating result, not using
the library in the meantime and calling xmlCleanupParser() twice (or
more) in a perfectly legal way.

  And there is nothing more frustrating than a library outputting
a warning to some uncontrolled channel, because it thinks it's
appropriate to do so, but making the user mad because the programmer
might have made a mistake (or not). Latest fun example being

  libnuma: Warning: /sys not mounted or no numa system. Assuming one
  node: No such file or directory

for anybody running an application using libnuma on a non NUMA system.
Annoying the user is not a substitute for warning the programmer.

I have tried to clearly explain the problem in the documentation, raised
the point many time on the xml at gnome.org mailing-list, but maybe
something more drastic is needed. I could turn xmlCleanupParser()
into an empty entry point and create a new function where the name would
make clear that this is not to be used without being careful, but
that decision would have to be discussed on the above list, not here.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel at veillard.com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


More information about the devel mailing list