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 }
- depends on
-
CDRIVER-2455 Off by one error calculated required size with bson_append_regex
- Closed
- is related to
-
CDRIVER-2128 Support revised Extended JSON spec
- Closed
- links to