From: benjcarson at digitaljunkies dot ca
Operating system: Linux
PHP version: 5CVS-2004-11-09 (dev)
PHP Bug Type: Reproducible crash
Bug description: PHP segfaults when an exception is thrown in getIterator()
within foreach
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 bug report at http://bugs.php.net/?id=30725&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30725&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=30725&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=30725&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=30725&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=30725&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=30725&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=30725&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=30725&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=30725&r=support
Expected behavior: http://bugs.php.net/fix.php?id=30725&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=30725&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=30725&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=30725&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30725&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=30725&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=30725&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=30725&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=30725&r=float
MySQL Configuration Error: http://bugs.php.net/fix.php?id=30725&r=mysqlcfg