php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32087 PHP5 freezes when parsing XML document without prolog
Submitted: 2005-02-23 23:16 UTC Modified: 2005-02-25 22:33 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: kellan at pobox dot com Assigned:
Status: Not a bug Package: XML related
PHP Version: 5.0.3 OS: any (tested on os x and debian)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: kellan at pobox dot com
New email:
PHP Version: OS:

 

 [2005-02-23 23:16 UTC] kellan at pobox dot com
Description:
------------
When parsing a XML document without a prolog PHP5 seems to "freeze", never returning from xml_parse and never calling the call backs.  This is reproducible on both Debian/PHP 5.0.2 with libxml 2.6.11 and Mac OS X/PHP 5.0.3 with libxml 2.6.7 

I've attached the simplest possible example to demonstrate this (probably best to run it from the command line, but the problem is reproducible running under Apache and from the command line)

Reproduce code:
---------------
<?php

$xml1 = '<?xml version="1.0"?><greeting>hello world</greeting>';
$xml2 = '<greeting>hello world</greeting>';
$parser = xml_parser_create('');
xml_set_element_handler($parser, "startElement", "endElement");
$status = xml_parse($parser, $xml1, true);
	
function startElement($parser, $name, $attrs) {
	echo "start $name\n";
}

function endElement($parser, $name) {
	echo "end $name\n";
}


?>

Expected result:
----------------
I would expect to see the program echo "GREETING", and then end.  This is what happens when you run this same script under PHP4

Actual result:
--------------
It just sits there until you kill it.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-24 19:19 UTC] mbonetti at gmail dot com
Freezing doesn't happen with the provided code snipped, unless you replace $xml1 with $xml2 in the xml_parse() call.

Reproduced on OS X 10.3.8, php 5.0.2 (both cli and web module), libxml 2.5.4
 [2005-02-25 11:15 UTC] tony2001@php.net
Verified on Linux with libxml-2.6.16.
Seems like a libxml bug to me.

Program received signal SIGINT, Interrupt.
[Switching to Thread 1089708384 (LWP 21170)]
0x40e53223 in xmlParseTryOrFinish (ctxt=0x85ac1b0, terminate=1) at parser.c:9038
9038    parser.c: No such file or directory.
        in parser.c
(gdb) bt
#0  0x40e53223 in xmlParseTryOrFinish (ctxt=0x85ac1b0, terminate=1) at parser.c:9038
#1  0x40e5488f in xmlParseChunk__internal_alias (ctxt=0x85ac1b0, chunk=0x8593aec "<greeting>hello world</greeting>", size=140145336, terminate=1) at parser.c:9872
#2  0x08237ca7 in php_XML_Parse (parser=0x85ac164, data=0x8593aec "<greeting>hello world</greeting>", data_len=32, is_final=1) at /usr/src/dev/php-src/ext/xml/compat.c:481
#3  0x082361ac in zif_xml_parse (ht=3, return_value=0x85ad1bc, this_ptr=0x0, return_value_used=1) at /usr/src/dev/php-src/ext/xml/xml.c:1333
#4  0x082a23f4 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfffcbd0) at zend_vm_execute.h:175
#5  0x082a4e98 in ZEND_DO_FCALL_SPEC_CONST_HANDLER (execute_data=0xbfffcbd0) at zend_vm_execute.h:1535
#6  0x082a210e in execute (op_array=0x85a71bc) at zend_vm_execute.h:78
#7  0x0827e5e3 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/dev/php-src/Zend/zend.c:1058
#8  0x0823c0a1 in php_execute_script (primary_file=0xbffff000) at /usr/src/dev/php-src/main/main.c:1641
#9  0x082f13c1 in main (argc=2, argv=0xbffff0d4) at /usr/src/dev/php-src/sapi/cli/php_cli.c:944
 
 [2005-02-25 20:14 UTC] pajoye@php.net
Hello,

Please try with libxml2-2.6.17 or cvs snapshot. It works well here using both of them.

--Pierre
 [2005-02-25 22:33 UTC] rrichards@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

verified that this is same as bug #32001
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 23 01:01:30 2024 UTC