Subject: | Parser is not thread safe |
Try this in multiple threads simultaneously:
my $dtd = XML::LibXML::Dtd->new("xxxxx", xxxxxx);
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file(xxxxx);
$doc->validate($dtd);
It SEGVs very quickly. Note that I am not sharing any data between threads. If you put a lock around the above block, the SEGV goes away. This is on Fedora Core 4 x86 with Perl 5.8.6.
Here is the trace:
#0 0x00233475 in LibXML_validity_warning ()
from /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi/auto/XML/LibXML/LibXML.so
#1 0x0025bb51 in XS_XML__LibXML__Dtd_new ()
from /usr/lib/perl5/vendor_perl/5.8.6/i386-linux-thread-multi/auto/XML/LibXML/LibXML.so
#2 0x0278298c in Perl_pp_entersub () from /usr/lib/perl5/5.8.6/i386-linux-thread-multi/CORE/libperl.so
#3 0x027646e1 in Perl_runops_debug () from /usr/lib/perl5/5.8.6/i386-linux-thread-multi/CORE/libperl.so
#4 0x02711b9e in Perl_get_cv () from /usr/lib/perl5/5.8.6/i386-linux-thread-multi/CORE/libperl.so
#5 0x027162e5 in Perl_call_sv () from /usr/lib/perl5/5.8.6/i386-linux-thread-multi/CORE/libperl.so
#6 0x0093ccba in Perl_ithread_run () from /usr/lib/perl5/5.8.6/i386-linux-thread-multi/auto/threads/threads.so
#7 0x007f8b80 in start_thread () from /lib/libpthread.so.0
#8 0x00750dee in clone () from /lib/libc.so.6