レナート   TBFKAYIBYNYAAYB   ﻟﻴﻨﺎﺭﺕ

Wed, 13 Jan 2010

Public Service Announcement: Beware of xmlCleanupParser()!

Everyone and his dog seem to call libxml2's xmlCleanupParser() at inappropriate places. For example Empathy does it, and Abiword does it too. Google Code Search seems to reveal at least Inkscape and Dia do it as well.

So, please, if your project links against libxml2 verify that it calls xmlCleanupParser() only once, and right before exiting! And if it calls it more often or somewhere else, then please fix that!

For more information see my post on fedora-devel.

Thanks for your time.

posted at: 00:29 | path: /projects | permanent link to this entry | 5 comments


Posted by foo at Wed Jan 13 03:24:16 2010
More culprits can be found here:

http://source.debian.net/source/search?q=xmlCleanupParser

Posted by Axel at Wed Jan 13 13:54:28 2010
This seems like a design mistake in libxml2. One simply can't reliably use that library inside of any other library, or it might muck up application state. Ideally, one should be able to create separate libxml contexts for use in each library, and then selectively destroy that specific context only.

But given that libxml2 has an api that is more or less set in stone, the best workaround I can see would be to count how many times libxml2 has been initialized, and ignore all calls of xmlCleanupParser until it has been called the same number of times. This might still has some threading issues, and it might use more memory than thoretically needed, but it should free all memory before an application exits and it should not cause the app to crash unexpectedly.

Posted by Lennart at Wed Jan 13 14:22:14 2010
Axel: nah, people should just stop calling that function alltogether. There is no need to call it it under normal coricumstances. The only reason there could be is to make tha app appear valgrind clean.

Posted by Axel at Wed Jan 13 15:31:38 2010
First of all, if apps shouldn't actually call the function, it should be turned into a no-op. Having a big shiny button that destroys the world with a nice helpful message next to it about not pressing it is not constructive.

Secondly, making apps Valgrind clean is a very good reason to call a function.

Posted by elektroauto at Thu Sep 2 14:38:27 2010
Hi there! I have read your article, and I must say it’s quite fascinating. What you have written is a general feeling but the way you have embedded the feeling into text is admirable.
<A HREF="http://www.wasserauto24.de/Elektroauto.html">elektroauto</A>

Leave a Comment:

Your Name:


Your E-mail (optional):


Comment:


As a protection against comment spam, please type the following number into the field on the right:
Secret Number Image

Please note that this is neither a support forum nor a bug tracker! Support questions or bug reports posted here will be ignored and not responded to!


It should be obvious but in case it isn't: the opinions reflected here are my own. They are not the views of my employer, or Ronald McDonald, or anyone else.

Please note that I take the liberty to delete any comments posted here that I deem inappropriate, off-topic, or insulting. And I excercise this liberty quite agressively. So yes, if you comment here, I might censor you. If you don't want to be censored your are welcome to comment on your own blog instead.


Lennart Poettering <mzoybt (at) 0pointer (dot) net>
Syndicated on Planet GNOME, Planet Fedora, planet.freedesktop.org, Planet Debian Upstream. feed RSS 0.91, RSS 2.0
Archives: 2005, 2006, 2007, 2008, 2009, 2010

Valid XHTML 1.0 Strict!   Valid CSS!