#27010 [NEW]: segfault and node text not displayed when returned from children()
| From: | web-php-bugs at sklar dot com | Date: | Thu, 22 Jan 2004 19:08:37 +0000 |
| Subject: | #27010 [NEW]: segfault and node text not displayed when returned from children() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-53767@lists.php.net to get a copy of this message | ||
From: web-php-bugs at sklar dot com
Operating system: Linux
PHP version: 5CVS-2004-01-22 (dev)
PHP Bug Type: XML related
Bug description: segfault and node text not displayed when returned from children()
Description:
------------
When iterating through the results of the SimpleXML children() method,
$element->name syntax returns the empty string instead of the text of the
"name" tag. var_dump($element), however reports the correct value for the
"name" property of $element.
Reproduce code:
---------------
$xml='
<drinks xmlns:hot="http://www.example.com/hot">
<hot:drink><hot:name>Coffee</hot:name></hot:drink>
<hot:drink><hot:name>Tea</hot:name></hot:drink>
<drink><name>Cola</name></drink>
<drink><name>Juice</name></drink>
</drinks>';
$sxe = simplexml_load_string($xml);
foreach ($sxe as $element_name => $element) {
print "$element_name is $element->name\n";
}
foreach ($sxe->children('http://www.example.com/hot') as $element_name =>
$element) {
print "$element_name is $element->name\n";
}
Expected result:
----------------
drink is Cola
drink is Juice
drink is Coffee
drink is Tea
Actual result:
--------------
drink is Cola
drink is Juice
drink is
drink is
Segmentation fault
Substituting var_dump($element) for the print statement produces:
object(simplexml_element)#5 (1) {
["name"]=>
string(6) "Coffee"
}
object(simplexml_element)#4 (1) {
["name"]=>
string(3) "Tea"
}
[New Thread 1076484640 (LWP 16144)]
drink is Cola
drink is Juice
drink is
drink is
On the segfault, GDB reports:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1076484640 (LWP 16144)]
0x080eb813 in match_ns (sxe=0x402af9d4, node=0x835c910,
name=0x835c4b8 "http://www.example.com/hot")
at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:124
124 if (!xmlStrcmp(node->ns->href, name)) {
(gdb) bt
#0 0x080eb813 in match_ns (sxe=0x402af9d4, node=0x835c910,
name=0x835c4b8 "http://www.example.com/hot")
at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:124
#1 0x080eb2d6 in php_sxe_move_forward_iterator (sxe=0x402af9d4)
at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:1394
#2 0x080eb3ea in php_sxe_iterator_move_forward (iter=0x402af94c)
at /opt/cvs/cvs.php.net/php-src/ext/simplexml/simplexml.c:1424
#3 0x082390c5 in zend_fe_fetch_handler (execute_data=0xbfffd5c0,
op_array=0x402adb6c)
at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:3672
#4 0x0823221f in execute (op_array=0x402adb6c)
at /opt/cvs/cvs.php.net/php-src/Zend/zend_execute.c:1264
#5 0x08210d11 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at /opt/cvs/cvs.php.net/php-src/Zend/zend.c:1051
#6 0x081ce776 in php_execute_script (primary_file=0xbffff9c0)
at /opt/cvs/cvs.php.net/php-src/main/main.c:1642
#7 0x0824252c in main (argc=2, argv=0xbffffa54)
at /opt/cvs/cvs.php.net/php-src/sapi/cli/php_cli.c:939
#8 0x42015704 in __libc_start_main () from /lib/tls/libc.so.6
(gdb) p *node
$1 = {_private = 0x0, type = XML_ELEMENT_NODE, name = 0x835c900 "drink",
children = 0x835c968, last = 0x835c968, parent = 0x835c5d8,
next = 0x835c9e8, prev = 0x835c8c8, doc = 0x835c4f0, ns = 0x0,
content = 0x0, properties = 0x0, nsDef = 0x0}
--
Edit bug report at http://bugs.php.net/?id=27010&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27010&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27010&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27010&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27010&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27010&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27010&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27010&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27010&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27010&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27010&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27010&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27010&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27010&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27010&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27010&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27010&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27010&r=float