Subject: | "Invalid expression" error from XML::Diff |
Date: | Wed, 14 May 2008 16:19:15 -0500 |
To: | bug-XML-Diff [...] rt.cpan.org |
From: | Peter Fales <psfales [...] alcatel-lucent.com> |
We've observed cases where running an XML::Diff "compare" operation on
two files results in the message "Invalid Expression" being printed on
stderr followed by an abnormal termination.
I've gotten far enough in debugging to determine that this happens when
the string "?/entity" is passed to xmlXPathCompile, but I don't understand
XML::Diff well enough to know where that is coming from. That string
does not appear in our XML input (which appears to be correct and
valid). Only some input files trigger the problem, and even files with
fairly similar size or contents may not show the problem.
It feels a little like a memory corruption or resource error, but the
same input triggers the problem on a variety of different systems
(Solaris 2.5.1 sparc, Solaris 8 sparc, Solaris 8 intel, RedHat Linux 7.3,
RedHat Linux 9, and Fedora 8).
Here's how to reproduce it.
First, run this shell script to generate the files "string1.xml" and
"string2.xml"
###############################################################
COUNT=${1:-700}
echo '<entitytype n="SSSSSSSSSSSSS">' > string1.xml
for i in `seq $COUNT`
do
cat >> string1.xml <<!
<entity>
<keyfld n="AAAAAAA" v="1" />
<keyfld n="BBBBBBBBBB" v="28" />
<keyfld n="CCCCCCCCCC" v="175" />
<keyfld n="DDDDDDDD" v="$i-1" />
<keyfld n="EEEEEEEEE" v="1" />
<fld n="TEST" v="$i-1" />
<fld n="FFFFFFFFFFF" v="No" />
<fld n="GGGGGGGGGGGGGGGGGGGGGGGGGGG" v="20" />
<fld n="HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH" v="0" />
<fld n="IIIIIIIIIIIIIIIIIIIIIIIII" v="3.0" />
<fld n="JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ" v="5.0" />
<fld n="KKKKKKKKKKKKKKKKKKKKK" v="-7.0" />
<fld n="LLLLLLLLLLLLL" v="Unspecified" />
<fld n="MMMMMMMMMMMMMM" v="No" />
<fld n="NNNNNNNNNNNNNNNNNNNNNNNNNN" v="_" />
<fld n="OOOOOOOOOOOOOOOOOOOOO" v="0" />
<fld n="PPPPPPPPPPPPPPPPP" v="59" />
<fld n="QQQQQQQQQQQQQQQQQQQQQ" v="0" />
<fld n="RRRRRRRRRRRRRRRRRRRR" v="0" />
<fld n="SSSSSSSSSSSSSSSSSSSSS" v="0" />
<fld n="TTTTTTTTTTTTTTTTTTTTT" v="0" />
<fld n="UUUUUUUUUUUUUUUUUUUUU" v="0" />
<fld n="VVVVVVVVVVVVVVVVVVVVV" v="0" />
<fld n="WWWWWWWWWWWWWWWW" v="Unspecified" />
<fld n="XXXXXXXXXXXXXXXXXXXXXXXXXXX" v="Unspecified" />
<fld n="ZZZZZZZZZZZZZZZZZZZZZZZ" v="_" />
<fld n="aaaaaaaaaaaaaaaaaaaaaaaaa" v="Unspecified" />
<fld n="bbbbbbbbbbbbbbbbbbb" v="_" />
<fld n="cccccccccccccccccccc" v="_" />
<fld n="dddddddddddddddddd" v="_" />
<fld n="eeeeeeeeeeeeeeeeeeee" v="_" />
<fld n="ffffffffffffffffffffffffff" v="_" />
<fld n="ggggggggggggggggggggggggg" v="_" />
<fld n="hhhhhhhhhhhhhh" v="_" />
<fld n="iiiiiiiiiiiiiiiiiii" v="_" />
<fld n="jjjjjjjjjjjjjjjjjjjjj" v="_" />
<fld n="kkkkkkkkkkkkkkkkkk" v="_" />
<fld n="lllllllllllllllll" v="_" />
<fld n="mmmmmmmmmmmmmmmmmm" v="_" />
<fld n="nnnnnnnnnnnnnnnnnn" v="_" />
<fld n="oooooooooooooooooooo" v="_" />
<fld n="pppppppppppppppppppppppppppp" v="_" />
<fld n="rrrrrrrrrrrrrrrrrrrrrrrrrrr" v="_" />
<fld n="ssssssssssssssssssssss" v="_" />
<fld n="tttttttttttttttttttttttttttt" v="Disabled" />
<fld n="uuuuuuuuuuuuuuuuuuuuuuuu" v="0" />
<fld n="vvvvvvvvvvvvvvvvvvvvvv" v="0" />
</entity>
!
done
echo '</entitytype>' >> string1.xml
echo '<entitytype n="SSSSSSSSSSSSS">' > string2.xml
for i in `seq $COUNT`
do
cat >> string2.xml <<!
<entity>
<keyfld n="AAAAAAA" v="1" />
<keyfld n="BBBBBBBBBB" v="28" />
<keyfld n="CCCCCCCCCC" v="175" />
<keyfld n="DDDDDDDD" v="$i-1" />
<keyfld n="EEEEEEEEE" v="1" />
<fld n="test" v="$i-2" />
<fld n="FFFFFFFFFFF" v="No" />
<fld n="GGGGGGGGGGGGGGGGGGGGGGGGGGG" v="20" />
<fld n="HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH" v="0" />
<fld n="IIIIIIIIIIIIIIIIIIIIIIIII" v="3.0" />
<fld n="JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ" v="5.0" />
<fld n="KKKKKKKKKKKKKKKKKKKKK" v="-7.0" />
<fld n="LLLLLLLLLLLLL" v="Unspecified" />
<fld n="MMMMMMMMMMMMMM" v="No" />
<fld n="NNNNNNNNNNNNNNNNNNNNNNNNNN" v="_" />
<fld n="OOOOOOOOOOOOOOOOOOOOO" v="0" />
<fld n="PPPPPPPPPPPPPPPPP" v="59" />
<fld n="QQQQQQQQQQQQQQQQQQQQQ" v="0" />
<fld n="RRRRRRRRRRRRRRRRRRRR" v="0" />
<fld n="SSSSSSSSSSSSSSSSSSSSS" v="0" />
<fld n="TTTTTTTTTTTTTTTTTTTTT" v="0" />
<fld n="UUUUUUUUUUUUUUUUUUUUU" v="0" />
<fld n="VVVVVVVVVVVVVVVVVVVVV" v="0" />
<fld n="WWWWWWWWWWWWWWWW" v="Unspecified" />
<fld n="XXXXXXXXXXXXXXXXXXXXXXXXXXX" v="Unspecified" />
<fld n="ZZZZZZZZZZZZZZZZZZZZZZZ" v="_" />
<fld n="aaaaaaaaaaaaaaaaaaaaaaaaa" v="Unspecified" />
<fld n="bbbbbbbbbbbbbbbbbbb" v="_" />
<fld n="cccccccccccccccccccc" v="_" />
<fld n="dddddddddddddddddd" v="_" />
<fld n="eeeeeeeeeeeeeeeeeeee" v="_" />
<fld n="ffffffffffffffffffffffffff" v="_" />
<fld n="ggggggggggggggggggggggggg" v="_" />
<fld n="hhhhhhhhhhhhhh" v="_" />
<fld n="iiiiiiiiiiiiiiiiiii" v="_" />
<fld n="jjjjjjjjjjjjjjjjjjjjj" v="_" />
<fld n="kkkkkkkkkkkkkkkkkk" v="_" />
<fld n="lllllllllllllllll" v="_" />
<fld n="mmmmmmmmmmmmmmmmmm" v="_" />
<fld n="nnnnnnnnnnnnnnnnnn" v="_" />
<fld n="oooooooooooooooooooo" v="_" />
<fld n="pppppppppppppppppppppppppppp" v="_" />
<fld n="rrrrrrrrrrrrrrrrrrrrrrrrrrr" v="_" />
<fld n="ssssssssssssssssssssss" v="_" />
<fld n="tttttttttttttttttttttttttttt" v="Disabled" />
<fld n="uuuuuuuuuuuuuuuuuuuuuuuu" v="0" />
<fld n="vvvvvvvvvvvvvvvvvvvvvv" v="0" />
<fld n="wwwwwwwwwwwwwwwwwwwwwwwww" v="_" />
<fld n="xxxxxxxxxxxxxxxxxxxxxxxxxxx" v="_" />
<fld n="zzzzzzzzzzzzzzzzzzzzzz" v="_" />
<fld n="111111111111111111111111" v="_" />
<fld n="2222222222222222" v="_" />
<fld n="3333333333333333333" v="_" />
</entity>
!
done
echo '</entitytype>' >> string2.xml
###############################################################
Then, run this perl program. (It assumes that XML::Diff is installed)
The expected result is normal termination. Instead, the message
"Invalid expression" is printed and the program exits with an error.
###############################################################
#!/usr/bin/perl
use XML::Diff;
my $diff = XML::Diff->new();
my $diffgram = $diff->compare( -old => "string1.xml", -new => "string2.xml" );
###############################################################
Thanks!
--
Peter Fales
Alcatel-Lucent
Member of Technical Staff
2000 Lucent Lane
Room: 1C-436
Naperville, IL 60566-7033
Email: psfales@alcatel-lucent.com
Phone: 630 979 8031