|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-01-24 21:05 UTC] helly@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 23 16:00:01 2025 UTC |
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