GNOME Bugzilla – Bug 614157
API docs should warn about the risks of rsvg_term()
Last modified: 2011-12-15 14:05:19 UTC
Currently rsvg_term() docs just says it deinitializes rsvg letting the user assume that it's reasonable to initialize multiple contexts of rsvg as long as each one is delimited by an _init() and a _term() call. This is wrong because rsvg_term() calls xmlCleanupParser, that clean the whole memory owned by libxml causing bad crashes with multithread applications if not done right before exit. See for reference bug 592100 and the following links: http://0pointer.de/blog/projects/beware-of-rsvg-term.html http://0pointer.de/blog/projects/beware-of-xmlCleanupParser Quoting from libxml doc: "WARNING: if your application is multithreaded or has plugin support calling this may crash the application if another thread or a plugin is still using libxml2. It's sometimes very hard to guess if libxml2 is in use in the application, some libraries or plugins may use it without notice. In case of doubt abstain from calling this function or do it just before calling exit() to avoid leak reports from valgrind !" I think we should really have a similar big WARNING in rsvg docs too.
How about libxml2 not keep around so much global state?
This is fixed on master. I made rsvg_term() a no-op and added a rsvg_cleanup() with a note to say you shouldn't use it, normally.