Re: [xml] 2.4.27 thread problems



Well, today it's not raining ... I found the problem.

First, the only reason I got into this mail thread was because I
wanted to prove that Igor's modification to the spaces in the
threads.c source was the real root cause ;-).  Now, after almost two
full days of low-level debugging, at least I can say that the
problem was within the threads.c module.

Actually, the problem has been present for quite awhile, and must
have had some other bad effects in the past.  For anyone interested,
I describe the problem in detail below.  For those not interested
but wanting to use multi-threading, the problem which I found has
been fixed in CVS.

As mentioned in my last mail, the problem was exposed by the change
within xmlInitParserCtxt where the contents of xmlDefaultSAXHandler
were copied into the xmlSAXHandler structure.  However, there was
absolutely nothing wrong with that action.  When the library is
configured --with-threads, xmlDefaultSAXHandler is redefined to be a
macro based upon a "global state" which is unique to the thread, and
so there is no problem with respect to interference from other
threads.

Rather, the problem was caused by an error within the routine
xmlNewGlobalState.  Because of an incorrect "sizeof" statement, the
newly allocated memory was not being properly cleared before use. 
That in turn meant that, on certain (randomly occurring) instances,
the thread-local xmlDefaultSAXHandler was not initialized at all,
and later usage of the pointers within that structures actually
caused the crash.

Hope that will help, and also hope it works okay on other than x86
linux platforms (the only one I can test on).

Regards,
Bill





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