Bug #65166 [Com]: PHP Generator yield causing zend_mm_heap corrupted
| From: | nikic@php.net | Date: | Sat, 29 Jun 2013 22:18:03 +0000 |
| Subject: | Bug #65166 [Com]: PHP Generator yield causing zend_mm_heap corrupted | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-179979@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65166&edit=1
ID: 65166
Comment by: nikic@php.net
Reported by: gavroche dot bull at gmail dot com
Summary: PHP Generator yield causing zend_mm_heap corrupted
Status: Open
Type: Bug
Package: Unknown/Other Function
PHP Version: master-Git-2013-06-29 (Git)
Block user comment: N
Private report: N
New Comment:
Is it possible to reproduce this crash without the use of mongo db?
If not, it would be nice to have a backtrace for this (as described on https://bugs.php.net/bugs-generating-backtrace.php).
Previous Comments:
------------------------------------------------------------------------
[2013-06-29 21:59:27] gavroche dot bull at gmail dot com
Description:
------------
The yield function in the example below gives a "zend_mm_heap corrupted" error.
Test script:
---------------
function dump($chunk = 500)
{
$m = new MongoClient();
$db = $m->dbname;
$collection = $db->selectCollection('collectionname');
$cursor = $collection->find();
$count = 0;
$output = [];
foreach ($cursor as $doc) {
$doc = array_filter($doc, function($v) { return !is_object($v); });
$output[] = $doc;
$count++;
if ($count === $chunk) {
yield json_encode($output);
$output = [];
$count = 0;
}
}
yield json_encode($output);
}
foreach(dump() as $dump) {
var_dump($dump);
}
Expected result:
----------------
No error.
Actual result:
--------------
zend_mm_heap corrupted
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65166&edit=1