Re: [xml] Windows threading issues

On Thu, Jul 10, 2003 at 11:33:46AM -0400, Jesse Pelton wrote:
I'm hoping someone on the list has enough experience with Windows
multithreading and libxml (Igor? Stephane?) to help with a problem I'm

  Honnestly I'm a bit lost there, so yes if someone else can check this
I would be grateful.

The situation is this: I'm using libxml 2.5.8 (statically linked) in an
ISAPI DLL running under IIS 5, and I'm not sure how to build the library so
it cleans up its thread-local "global" data correctly. I started with
LIBXML_STATIC defined (because it seemed like the right thing to do, since
I'm statically linking to the library), but this often crashes at exit.
(There's a cleanup thread that calls WaitForSingleObject(), but by the time
the wait returns, the thread's code has been unloaded, leading to an access
violation.) If I leave LIBXML_STATIC undefined, theory has it that libxml's
DllMain() will use DLL_THREAD_DETACH and DLL_PROCESS_DETACH calls to clean
up properly - but then libxml's DllMain() conflicts with my own. If I were
to remove libxml's DllMain(), my own DllMain() couldn't clean up, because it
wouldn't have access to required static variables.

It looks to me like libxml is not presently designed to work as a library
statically linked into a DLL. If I'm right, a solution might be to make
libxml's DllMain() conditional on another preprocessor constant and add a
cleanup function that either libxml's DllMain() or another DllMain() could

So, my questions:
1) Does my assessment that libxml needs a patch to work in my scenario make
2) If so, does my solution make sense, or is there a better approach?

I'm happy to attempt a patch if necessary.

  I wonder how much this is related to the Windows extra token we planned
to add to the includes (Sorry about this Igor, I realize I never answered 
<grin/> to your mail asking for feedback).


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]