Edit report at https://bugs.php.net/bug.php?id=65166&edit=1

 ID:                 65166
 Comment by:         gavroche dot bull at gmail dot com
 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:

Actually after investigation more, this code alone does not produce the error. 
But 
it now seems that having too much lines of code in the script will produce this 
error or a segmentation fault error. 

For example, if I remove unused lines of code, the code execute properly. If I 
change those unused lines of code for other lines like "null;", the error 
appears 
again.


Previous Comments:
------------------------------------------------------------------------
[2013-06-29 22:18:03] ni...@php.net

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).

------------------------------------------------------------------------
[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

Reply via email to