ID: 30725
Updated by: [EMAIL PROTECTED]
Reported By: benjcarson at digitaljunkies dot ca
-Status: Open
+Status: Assigned
Bug Type: Reproducible crash
Operating System: Linux
PHP Version: 5CVS-2004-11-09 (dev)
Assigned To: helly
Previous Comments:
------------------------------------------------------------------------
[2004-11-09 00:47:24] benjcarson at digitaljunkies dot ca
Description:
------------
When an object implementing IteratorAggregate is used within a foreach
loop, PHP will segfault if an exception is thrown within getIterator().
Reproduce code:
---------------
<?php
class Iter implements IteratorAggregate {
function getIterator() {
throw new Exception('exception');
}
}
$test = new Iter();
foreach($test as $val)
echo "foo";
?>
Expected result:
----------------
Fatal error: Uncaught exception 'Exception' with message 'exception' in
/home/benj/projects/bugs/spl_foreach.php:5
Stack trace:
#0 {main}
thrown in /home/benj/projects/bugs/spl_foreach.php on line 5
Actual result:
--------------
Segmentation fault (core dumped)
Here's a backtrace:
#0 zend_user_it_get_new_iterator (ce=0x8515b64, object=0x850622c) at
/usr/src/php/php-src/Zend/zend_interfaces.c:273
#1 0x08251d8c in ZEND_FE_RESET_SPEC_CV_HANDLER
(execute_data=0xbfffd590) at zend_vm_execute.h:18131
#2 0x0821b448 in execute (op_array=0x851068c) at zend_vm_execute.h:58
#3 0x081f981f in zend_execute_scripts (type=8, retval=0x0,
file_count=3) at /usr/src/php/php-src/Zend/zend.c:1053
#4 0x081bd5bf in php_execute_script (primary_file=0xbffff990) at
/usr/src/php/php-src/main/main.c:1634
#5 0x0828704e in main (argc=2, argv=0xbffffa54) at
/usr/src/php/php-src/sapi/cli/php_cli.c:943
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30725&edit=1