Bug #69221 [Asn->Csd]: Segmentation fault when using a generator in combination with an Iterator

From: Date: Fri, 13 Mar 2015 15:31:19 +0000
Subject: Bug #69221 [Asn->Csd]: Segmentation fault when using a generator in combination with an Iterator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191374@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69221&edit=1 ID: 69221 Updated by: nikic@php.net Reported by: jose dot zap at gmail dot com Summary: Segmentation fault when using a generator in combination with an Iterator -Status: Assigned +Status: Closed Type: Bug Package: SPL related Operating System: Linux PHP Version: 5.6.6 Assigned To: nikic Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikic Revision: http://git.php.net/?p=php-src.git;a=commit;h=a9d73f0646ca95134f5f2ada0899a7616c1ea705 Log: Fixed bug #69221 Previous Comments: ------------------------------------------------------------------------ [2015-03-11 15:40:02] nikic@php.net Simplified reproduce code: <?php $gen = function() { yield 1; }; $iter = new IteratorIterator($gen()); $ngen = $iter->getInnerIterator(); iterator_to_array($ngen, false); ------------------------------------------------------------------------ [2015-03-11 15:17:07] jose dot zap at gmail dot com Description: ------------ When combining a generator with a custom IteratorIterator, after iterating the elements of the object I get a segmentation fault. Test script: --------------- <?php $gen = function() { yield 1; }; $iter = new IteratorIterator($gen()); $ngen = $iter->getInnerIterator(); class ReplaceIterator extends IteratorIterator { private $cb; function __construct($iter, $cb) { parent::__construct($iter); $this->cb = $cb; } function current() { $cb = $this->cb; return $cb(parent::current()); } } $filter = new ReplaceIterator($ngen, function($a){ return $a; }); iterator_to_array($filter, false); Actual result: -------------- #0 0x00000000006f0e29 in gc_zval_possible_root (zv=0x7ffff7fd9398) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_gc.c:143 #1 0x00000000006f2877 in zend_generator_iterator_dtor (iterator=<optimized out>) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_generators.c:610 #2 0x00000000006f9d60 in zend_objects_store_del_ref_by_handle_ex (handle=2, handlers=<optimized out>) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_objects_API.c:212 #3 0x00000000006f9da3 in zend_objects_store_del_ref (zobject=0x7ffff7fdc040) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_objects_API.c:178 #4 0x00000000006c1090 in _zval_dtor (zvalue=0x7ffff7fdc040) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_variables.h:35 #5 i_zval_ptr_dtor (zval_ptr=0x7ffff7fdc040) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_execute.h:81 #6 _zval_ptr_dtor (zval_ptr=<optimized out>) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_execute_API.c:423 #7 0x00000000006ddcc5 in zend_hash_apply_deleter (ht=ht@entry=0xea53a8, p=p@entry=0x7ffff7fd93c8) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_hash.c:650 #8 0x00000000006df801 in zend_hash_reverse_apply (ht=ht@entry=0xea53a8, apply_func=apply_func@entry=0x6c0f60 <zval_call_destructor>) at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_hash.c:804 #9 0x00000000006c13a1 in shutdown_destructors () at /usr/src/php5.5/source/dotdeb-php5/Zend/zend_execute_API.c:214 #10 0x00000000006d1007 in zend_call_destructors () at /usr/src/php5.5/source/dotdeb-php5/Zend/zend.c:930 #11 0x000000000066f5b5 in php_request_shutdown (dummy=dummy@entry=0x0) at /usr/src/php5.5/source/dotdeb-php5/main/main.c:1750 #12 0x0000000000782d98 in do_cli (argc=2, argv=0xea6cf0) at /usr/src/php5.5/source/dotdeb-php5/sapi/cli/php_cli.c:1177 #13 0x000000000043239f in main (argc=2, argv=0xea6cf0) at /usr/src/php5.5/source/dotdeb-php5/sapi/cli/php_cli.c:1378 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=69221&edit=1

« previous php.bugs (#191374) next »