Re: [xml] Race condition in xsltInit (thread safety)

On Wed, Feb 22, 2006 at 03:06:51PM -0500, Christopher R. Palmer wrote:
Daniel Veillard wrote:
On Mon, Feb 20, 2006 at 01:13:57PM -0500, Christopher R. Palmer wrote:
Digging into this a little more, it looks like xsltInit is called every 
time that a new stylesheet is parsed.  xsltInit uses 
xsltRegisterAllExtras which always updates all of the hash entries and 
the hash function is (not surprisingly) not thread safe for updates.

CVS tells me that xsltInit was changed to fix bug #165201 (calling 
xsltInit multiple times) where previously it had a local static 
initialized flag.

The best fix I can suggest is to export xsltInit and have a static 
initialized flag.  To not break the fix of bug #165201, add an internal 
function to signal that the library is no longer initialized.

I've attached such a patch for possible inclusion in the code base.

 Okay, this seems to make sense, and exporting the init function might
be the only way to garantee the absence of race in multithreaded uses.
I guess you tested it, I have no good way to test multithreaded uses,

I tested it as well as you can test a race condition...  Before the change, 
my multi-threaded service was crashing at least once a day and it hasn't 
crashed in several days now.

  Good, good, as I said it looks logical to me :-)


Daniel Veillard      | Red Hat
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]