|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 04:00:01 2025 UTC |
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