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

On čt 2. dubna 2009, Daniel Veillard wrote:
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

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 globals.c?

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,


I think the original reason for this was that when Perl bindings are 
used with mod_perl, there may be other (non-Perl) components using 
the global callbacks differently; that's why XML::LibXML Perl 
module tries to clean after itself (restoring whatever was in the 
callbacks previously). Is there any other way around this?

-- Petr

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