Subject: | Segfault with medium-sized document (30k elements) |
Hi there,
The attached code raises a segfault with perl-5.10.1 and perl-5.14.2.
Seems fine for other XML parsers such as XML::LibXML::SAX and
XML::TreeBuilder, and in XML::Twig for smaller documents (although
significantly slower than the other parsers).
Output of script on Linux/x64:
$ perl xmlbench.pl
Document is 1350062 chars
Benchmark: timing 10 iterations of tree, twig...
tree: 10.3706 wallclock secs (10.09 usr + 0.27 sys = 10.36 CPU) @
0.97/s (n=10)
Segmentation fault
perl -V output:
Summary of my perl5 (revision 5 version 14 subversion 2) configuration:
Platform:
osname=linux, osvers=2.6.35-30-generic, archname=x86_64-linux
uname='linux roku 2.6.35-30-generic #56-ubuntu smp mon jul 11
20:01:08 utc 2011 x86_64 gnulinux '
config_args='-de -Dprefix=/home/tom/perl5/perlbrew/perls/perl-5.14.2'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
ccversion='', gccversion='4.4.5', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
/usr/lib/x86_64-linux-gnu /lib64 /usr/lib64
libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.12.1.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.12.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'
Characteristics of this binary (from libperl):
Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP
PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT
USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF
Built under linux
Compiled at Oct 3 2011 02:24:00
%ENV:
PERL5LIB="/home/tom/.cpan:/home/tom/.cpan/lib:/home/tom/.cpan/lib/perl5:/home/tom/.cpan/lib/perl5/site_perl:/home/tom/.cpan/lib/perl5/5.10.0/i486-linux-gnu-thread-multi:"
PERLBREW_HOME="/home/tom/.perlbrew"
PERLBREW_PATH="/home/tom/perl5/perlbrew/bin:/home/tom/perl5/perlbrew/perls/perl-5.14.2/bin"
PERLBREW_PERL="perl-5.14.2"
PERLBREW_ROOT="/home/tom/perl5/perlbrew"
PERLBREW_VERSION="0.29"
PERL_LWP_SSL_VERIFY_HOSTNAME="0"
PERL_MM_USE_DEFAULT="1"
@INC:
/home/tom/.cpan
/home/tom/.cpan/lib
/home/tom/.cpan/lib/perl5
/home/tom/.cpan/lib/perl5/site_perl
/home/tom/.cpan/lib/perl5/5.10.0/i486-linux-gnu-thread-multi
/home/tom/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/x86_64-linux
/home/tom/perl5/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2
/home/tom/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2/x86_64-linux
/home/tom/perl5/perlbrew/perls/perl-5.14.2/lib/5.14.2
cheers,
Tom
Subject: | xmlbench.pl |
#!/usr/bin/perl
use strict;
use warnings;
use XML::Twig;
use XML::TreeBuilder;
use Benchmark qw(:hireswallclock);
my $xml = q{
<root>
}; $xml .= q{
<child>
<name>test name</name>
</child>
} for 0..30000;
$xml .= q{
</root>
};
warn "Document is " . length($xml) . " chars\n";
timethese(10, {
twig => sub {
my $parsed = XML::Twig->parse($xml);
},
tree => sub {
my $parsed = XML::TreeBuilder->new->parse($xml);
}
});