From:             gavroche dot bull at gmail dot com
Operating system: 
PHP version:      master-Git-2013-06-29 (Git)
Package:          Unknown/Other Function
Bug Type:         Bug
Bug description:PHP Generator yield causing zend_mm_heap corrupted

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 bug report at https://bugs.php.net/bug.php?id=65166&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65166&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65166&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65166&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65166&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65166&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65166&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65166&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65166&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65166&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65166&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65166&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65166&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65166&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65166&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65166&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65166&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65166&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65166&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65166&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65166&r=mysqlcfg

Reply via email to