Uploaded image for project: 'PHP Driver (Phongo)'
  1. PHP Driver (Phongo)
  2. PHPC-1067

BSON document produces driver segfault

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 1.3.4
    • Fix Version/s: 1.4.0, 1.4.0-RC1
    • Labels:
      None
    • # Replies:
      4
    • Last comment by Customer:
      true

      Description

      mongodb/mongo-php-library#449 reported a curious issue where using a specific document in a findOne query resulted in an InvalidArgumentException with the following message:

      Client Error: bad object in message: bson length doesn't match what we found in object with unknown _id

      This error message come from bson_validate.cpp in the server.

      The following script reproduces the error:

      $x = [
          '_______'                             => new MongoDB\BSON\ObjectID('111111111111111111111111'),
          '___________________________________' => new MongoDB\BSON\Regex('_______________________________________________________', 'i'),
      ];
       
      $manager = new MongoDB\Driver\Manager;
      $query = new MongoDB\Driver\Query($x);
      $manager->executeQuery('test.foo', $query);
      

      Aside from the error message, it's odd that this is reported as an InvalidArgumentException instead of a RuntimeException.

      Beyond this, attempting to insert the same document produces a segfault:

      $x = [
          '_______'                             => new MongoDB\BSON\ObjectID('111111111111111111111111'),
          '___________________________________' => new MongoDB\BSON\Regex('_______________________________________________________', 'i'),
      ];
       
      $manager = new MongoDB\Driver\Manager;
      $bulk = new MongoDB\Driver\BulkWrite;
      $bulk->insert($x);
      $manager->executeBulkWrite('test', $bulk);
      

      This appears to be specific to the PHP driver and libmongoc, as the document can be used just fine via the shell:

      > var x = {
      ...     "_______": ObjectId('111111111111111111111111'),
      ...     "___________________________________": RegExp("_______________________________________________________", "i")
      ... }
      > db.foo.insert(x)
      WriteResult({ "nInserted" : 1 })
      > db.foo.findOne(x)
      {
      	"_id" : ObjectId("5a31bad2384dbd1739b73f6d"),
      	"_______" : ObjectId("111111111111111111111111"),
      	"___________________________________" : /_______________________________________________________/i
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since reply:
                  48 weeks ago
                  Date of 1st Reply: