Red Hat Bugzilla – Bug 1473368
[abrt] perl-XML-XPath: XML_ParserFree(): perl killed by signal 6
Last modified: 2017-09-20 10:43:04 EDT
Description of problem:
attempting to run an xpath query on a 3MB XML file
Version-Release number of selected component:
cmdline: /usr/bin/perl /usr/bin/xpath -q -e //attribute[name="mcd_productcode"][text()="437"]
runlevel: N 5
Thread no. 1 (10 frames)
#6 XML_ParserFree at lib/xmlparse.c:1374
#7 XS_XML__Parser__Expat_ParserFree at Expat.xs:1432
#8 Perl_pp_entersub at pp_hot.c:3988
#9 Perl_runops_standard at run.c:41
#10 Perl_call_sv at perl.c:2807
#11 S_curse at sv.c:6869
#12 Perl_sv_clear at sv.c:6473
#13 Perl_sv_free2 at sv.c:6970
#14 Perl_leave_scope at scope.c:1096
#15 Perl_dounwind at pp_ctl.c:1548
Created attachment 1301842 [details]
Created attachment 1301843 [details]
Created attachment 1301844 [details]
Created attachment 1301845 [details]
Created attachment 1301846 [details]
Created attachment 1301847 [details]
Created attachment 1301848 [details]
Created attachment 1301849 [details]
Created attachment 1301850 [details]
Created attachment 1301851 [details]
Created attachment 1301852 [details]
Could you provide us the XML file? We need a complete reproducer to find the root cause.
Looking at the back trace, I think perl raised an exception (Perl_pp_die() call) and then glibc discovered a mistake in memory management when deallocating memory in the XML::Parer::Expat module (XS_XML__Parser__Expat_ParserFree() call).
Created attachment 1302467 [details]
A file that causes the error
This is as minimal as I can get the test file; if I remove any elements or change any element content the stack trace disappears (although it often still reports that it ran out of memory, depending on what was removed).
Thank you for the test file. I can reproduce it now.
It happens only if the file is redirected to the standard input. If I pass it positional argument, it finishes successfully without abortion or complains about insufficiency of memory.
Maybe if the file is read from standard input, an IO reference is used and as documented in the On Garbage Collection section of XML::XPath documentation, that can lead to memory leaks.
Minimal reproduced is feeding the test file to stdin of this script:
use open ':std', ':encoding(UTF-8)';
my $xpath = XML::XPath->new(ioref => \*STDIN);
The "use open ':std', ':encoding(UTF-8)';" pragma is important. It looks like there is some issue if PerlIO layer is employed together with IO reference in Expat parser.