[redland-dev] Threads

Lauri Aalto laalto at gmail.com
Wed Sep 9 21:13:15 CEST 2009


On Wed, Sep 9, 2009 at 8:23 PM, Michael Stahl<Michael.Stahl at sun.com> wrote:
> this raptor_world is a rather recent invention, right?
> looking at the documentation, i would assume that raptor_finish maybe
> frees some global data of other libraries, but raptor_free_world
> definitely does not. right? that would be nice...

Yes, raptor_world is a recently introduced mechanism to work around
problems caused by globa/thread-locall data inside Raptor.
Unfortunately it cannot work around global/thread-local data issues in
external libraries such as libxml2.

When writing code where libxml2 is used outside Raptor within the same
thread, at least make sure that xmlCleanupParser() is not called by
anyone before everyone has finished using libxml2. Raptor calls it in
raptor_sax2_finish(), called by raptor_free_world(), called by
raptor_finish(). Even then you may see weird stuff with error handlers
but they are not as likely to crash your program as using an already
cleaned up parser. There's raptor_sax2_initialised reference count in
the raptor_world structure, but it cannot prevent odd init-finish
patterns if there's more than one raptor_world per thread.

In some cases I've had to create a renamed copy of libxml2 shared
library to make one piece of code link to one copy of libxml2 and
raptor link to another copy, specifically just to give them separate
thread-local global data memory blocks.

Lauri


More information about the redland-dev mailing list