Re: [xml] IO callbacks are not thread-safe

On Thu, Mar 26, 2009 at 07:06:14PM +0100, Nick Wellnhofer wrote:

The input and output callbacks of libxml are stored in static arrays in
xmlIO.c, so any use of the callback functions is not thread-safe.

In many cases this shouldn't be a problem, if callbacks are registered
only at the start of a program. But the Perl bindings register and
unregister callbacks every time a document is parsed. I can reproduce

  Uhhhh ????
That sounds severely broken to me. Can you details why, and how ?

random segfaults or other errors when processing many thousand documents
in concurrent threads with the libxml Perl bindings.

I'm willing to help fix this, but I'm not sure about the correct
approach. Should the callback arrays be added to the global variables in

Those variables are not public, so I guess a different way would be
preferable. Still I can't see any good valid reason to change the values
all the time. Something is severely broken there in the perl bindings !
If they need a per parsing instance processing they should use the data
block provided by the I/O to make the switch, but register an unified
routine for all threads. No really this doesn't make any sense to me,
but maybe you can come up with a valid reason,


Daniel Veillard      | libxml Gnome XML XSLT toolkit
daniel veillard com  | Rpmfind RPM search engine | virtualization library

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