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

      1. testCase.php
        1 kB
        Dereckson

        Issue Links

          Activity

          Hide
          jmikola Jeremy Mikola added a comment -

          Closing as a duplicate of PHP-1063, which is responsible for fixing this issue.

          Regression test submitted as: https://github.com/mongodb/mongo-php-driver/pull/755

          Show
          jmikola Jeremy Mikola added a comment - Closing as a duplicate of PHP-1063 , which is responsible for fixing this issue. Regression test submitted as: https://github.com/mongodb/mongo-php-driver/pull/755
          Hide
          xgen-internal-githook Githook User added a comment -

          Author:

          {u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'}

          Message: PHP-977: Regression test for cursor iteration within generator
          Branch: master
          https://github.com/mongodb/mongo-php-driver/commit/055297f1d60df53ab799f4879811a28d8068f343

          Show
          xgen-internal-githook Githook User added a comment - Author: {u'username': u'jmikola', u'name': u'Jeremy Mikola', u'email': u'jmikola@gmail.com'} Message: PHP-977 : Regression test for cursor iteration within generator Branch: master https://github.com/mongodb/mongo-php-driver/commit/055297f1d60df53ab799f4879811a28d8068f343
          Hide
          remi Remi Collet added a comment -
          Show
          remi Remi Collet added a comment - Also reported as https://bugzilla.redhat.com/1162123
          Hide
          derick Derick Rethans added a comment -

          Remi Collet, this issue is marked as fixed for 1.6.0RC1. I have just confirmed that the test case in https://bugzilla.redhat.com/1162123 fails in 1.5.8, but works spotless with 1.6.0RC1.

          Show
          derick Derick Rethans added a comment - Remi Collet , this issue is marked as fixed for 1.6.0RC1. I have just confirmed that the test case in https://bugzilla.redhat.com/1162123 fails in 1.5.8, but works spotless with 1.6.0RC1.
          Hide
          remi Remi Collet added a comment -

          @derick, thanks.
          Fix in 5.6.0RC1 confirmed (see RH bug report).

          Show
          remi Remi Collet added a comment - @derick, thanks. Fix in 5.6.0RC1 confirmed (see RH bug report).

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Days since reply:
                2 years, 28 weeks ago
                Date of 1st Reply:

                  Agile