Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-977

An iteration on a MongoCursor object with yield produces a memory leak.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Duplicate
    • Affects Version/s: 1.4.5
    • Fix Version/s: 1.6.0RC1, 1.6.0
    • Component/s: pecl-mongo
    • Labels:
    • Environment:
      FreeBSD 8.1, PHP 5.5.9, MongoDB 2.4.6
    • # Replies:
      10
    • Last comment by Customer:
      true
    • Sprint:
      PHP Sprint 6 July 28 - Aug 15, PHP Sprint 10

      Description

      PHP 5.5 has introduced a way to implement simple iterators, called generators.

      The following function uses this construction to iterate in a MongoCursor:

      function getDocuments (MongoCollection $collection) {
      $items = $collection->find();

      foreach ($items as $item)

      { yield $item; }

      }

      A call to this method produces a segmentation fault of PHP. A test case script is attached to this bug.

      This bug has been submitted in the PHP bug tracker under the #66671:
      https://bugs.php.net/bug.php?id=66671

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                5 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since reply:
                  3 years, 1 week, 3 days ago
                  Date of 1st Reply: