Bug #69221 [NEW]: Segmentation fault when using a generator in combination with an Iterator
| From: | jose dot zap at gmail dot com | Date: | Wed, 11 Mar 2015 15:17:08 +0000 |
| Subject: | Bug #69221 [NEW]: Segmentation fault when using a generator in combination with an Iterator | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-191312@lists.php.net to get a copy of this message | ||
From: jose dot zap at gmail dot com
Operating system: Linux
PHP version: 5.6.6
Package: SPL related
Bug Type: Bug
Bug description:Segmentation fault when using a generator in combination with an Iterator
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 bug report at https://bugs.php.net/bug.php?id=69221&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69221&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69221&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69221&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69221&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69221&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69221&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69221&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69221&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69221&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69221&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69221&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69221&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69221&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69221&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69221&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69221&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69221&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69221&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69221&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69221&r=mysqlcfg