After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 614157 - API docs should warn about the risks of rsvg_term()
API docs should warn about the risks of rsvg_term()
Status: RESOLVED FIXED
Product: librsvg
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: librsvg maintainers
librsvg maintainers
Depends on:
Blocks:
 
 
Reported: 2010-03-28 08:00 UTC by Filippo Argiolas
Modified: 2011-12-15 14:05 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Filippo Argiolas 2010-03-28 08:00:29 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.
Comment 1 Dominic Lachowicz 2010-03-28 12:59:14 UTC
How about libxml2 not keep around so much global state?
Comment 2 Christian Persch 2011-12-15 14:05:19 UTC
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.