php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32754 Segmentation fault when running xpath
Submitted: 2005-04-18 22:50 UTC Modified: 2005-04-19 02:07 UTC
From: php at max-imp dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.0.4 OS: Red Hat
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at max-imp dot com
New email:
PHP Version: OS:

 

 [2005-04-18 22:50 UTC] php at max-imp dot com
Description:
------------
The code below causes a segmentation fault. The line it crashes on is
$nodelist = $xpath->query( '/*' );

The machine I have the problem on is running
PHP 5.0.4
libxml 2-2.6.19

On a different machine running the following we have no issues
PHP 5.0.4-dev
libxml 2.6.16

We have installed the newest snapshot of PHP as of the April 16th, but still had issues so we went back to PHP 5.0.4.

(There are a few notes in the code below.)

Thanks.


Reproduce code:
---------------
<?php
$x = new DOMDocument();


// This line gives a segmentation fault.
$x->loadXml( '<template xmlns="http://blah.com"/>');

// ... but if i comment the line above out and uncomment the next line there are no issues. It does not matter what xmlns is set to in the line above.
//$x->loadXml( '<template/>' );

$xpath = new DOMXPath( $x );
$nodelist = $xpath->query( '/*' );
?>

Expected result:
----------------
Nothing should really output in this example...but we expect no segmentation fault. :-)

Actual result:
--------------
Segmentation fault

This is what GDB gives me.
(gdb) run test.php
Starting program: /usr/local/bin/php test.php
[New Thread 1024 (LWP 18035)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 18035)]
__pthread_mutex_lock (mutex=0x1528) at mutex.c:99
99      mutex.c: No such file or directory.
        in mutex.c
(gdb) bt
#0  __pthread_mutex_lock (mutex=0x1528) at mutex.c:99
#1  0x402d2974 in __libc_free (mem=0x83b22a0) at malloc.c:3152
#2  0x4020c4c6 in xmlFreePatParserContext (ctxt=0x83b22a0) at pattern.c:293
#3  0x4020e3ef in xmlPatterncompile (pattern=0x83aa3dc "/*", dict=0x0, flags=0, namespaces=0x83af450) at pattern.c:1899
#4  0x401b282b in xmlXPathTryStreamCompile (ctxt=0x83b0760, str=0x83aa3dc "/*") at xpath.c:11270
#5  0x401b2afa in xmlXPathEvalExpr (ctxt=0x83af268) at xpath.c:11452
#6  0x401b2d53 in xmlXPathEvalExpression (str=0x83aa3dc "/*", ctxt=0x83b0760) at xpath.c:11549
#7  0x0808f552 in zif_dom_xpath_query (ht=1, return_value=0x83af224, this_ptr=0x83b228c, return_value_used=1) at /home/krisw/php-5.0.4/ext/dom/xpath.c:198
#8  0x4040b7e1 in get_module () from /usr/local/Zend/lib/Optimizer-2.5.7/php-5.0.x/ZendOptimizer.so
#9  0x4041985a in zend_oe () from /usr/local/Zend/lib/Optimizer-2.5.7/php-5.0.x/ZendOptimizer.so
#10 0x081714ee in php_execute_script (primary_file=0xbfffe0e0) at /home/krisw/php-5.0.4/main/main.c:1632
#11 0x081dd1e0 in main (argc=2, argv=0xbfffe184) at /home/krisw/php-5.0.4/sapi/cli/php_cli.c:946
#12 0x40272306 in __libc_start_main (main=0x81dc888 <main>, argc=2, ubp_av=0xbfffe184, init=0x807a580 <_init>, fini=0x81f9f10 <_fini>,
    rtld_fini=0x4000d2cc <_dl_fini>, stack_end=0xbfffe17c) at ../sysdeps/generic/libc-start.c:129
(gdb)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-19 02:04 UTC] php at max-imp dot com
Installing libxml 2.6.16 seems to have solved the issue. There seems to be some incompatibility issue between PHP 5.0.4 and libxml 2.6.19
 [2005-04-19 02:07 UTC] rrichards@php.net
Do not file bugs when you have Zend extensions (zend_extension=)
loaded. Examples are Zend Optimizer, Zend Debugger, Turck MM Cache,
APC, Xdebug and ionCube loader.  These extensions often modify engine
behavior which is not related to PHP itself.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 05 02:01:30 2024 UTC