Skip Menu |

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 41096
Status: resolved
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: SREZIC [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.69
Fixed in: (no value)



Subject: Segmentation fault in domXPathCompFindCtxt
I encounter segfaults when using XML::LibXML's findnodes() method. The problem seems to happen in domXPathCompFindCtxt. When looking at it in the debugger, the following things happens: 357 res = xmlXPathCompiledEval(comp, ctxt); (gdb) p ctxt->node $6 = 0xb7ebb68 (gdb) n 359 if ( tdoc != NULL ) { (gdb) p ctxt->node $7 = 0x0 So xmlXPathCompiledEval somehow set ctxt->node to NULL. Later in the function some variables are set to NULL and ctxt->node->doc = NULL; causes the segfault. The attached patch seems to workaround the problem, no segfaults anymore. The system is CentOS 4, with libxml2-2.6.32 installed, perl is 5.8.5. I don't see the problem on Debian, with the same libxml2 version, and perl 5.8.8. Sorry, the segfault happens in a complex system. I will try to construct a small testcase for reproducing. Regards, Slaven
Subject: XML-LibXML-1.69.domXPathCompFindCtxt.patch
Binary files XML-LibXML-1.69/blib/arch/auto/XML/LibXML/LibXML.so and new.XML-LibXML-1.69/blib/arch/auto/XML/LibXML/LibXML.so differ diff -ur XML-LibXML-1.69/xpath.c new.XML-LibXML-1.69/xpath.c --- XML-LibXML-1.69/xpath.c 2008-11-11 21:43:53.000000000 +0100 +++ new.XML-LibXML-1.69/xpath.c 2008-11-20 12:59:57.000000000 +0100 @@ -364,7 +364,9 @@ froot->parent = NULL; tdoc->children = NULL; tdoc->last = NULL; - ctxt->node->doc = NULL; + if ( ctxt->node ) { + ctxt->node->doc = NULL; + } xmlFreeDoc( tdoc ); } Binary files XML-LibXML-1.69/xpath.o and new.XML-LibXML-1.69/xpath.o differ
On Thu Nov 20 09:16:37 2008, SREZIC wrote: [...] Show quoted text
> The system is CentOS 4, with libxml2-2.6.32 installed, perl is 5.8.5. I > don't see the problem on Debian, with the same libxml2 version, and perl > 5.8.8.
This is not true. Segfaults also happen on Debian. Regards, Slaven
Attached is a small test case exposing the segmentation fault. It seems that it has to be a DocumentFragment involved, XPathContext, and a findnodes call with a namespace prefix in the xpath expression. Regards, Slaven
#!/usr/bin/perl use strict; use XML::LibXML 1.69; my $frag = XML::LibXML->new->parse_balanced_chunk(<<'EOF'); <h1>hello world</h1> EOF my $xc = XML::LibXML::XPathContext->new($frag); $xc->registerNs('cml','http://example.com/cml'); my @modules = $xc->findnodes('//cml:module');
Dne čt 20.lis.2008 11:08:44, SREZIC napsal(a): Show quoted text
> Attached is a small test case exposing the segmentation fault. It
seems Show quoted text
> that it has to be a DocumentFragment involved, XPathContext, and a > findnodes call with a namespace prefix in the xpath expression. > > Regards, > Slaven
Slaven, thanks for the report and the patch. I finally committed the patch to SVN, it'll appear soon in 1.70. -- Petr