-
Type: Bug
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: 1.24.0
-
Component/s: None
-
None
-
C Drivers
Summary
An assertion fails when creating a legacy exhaust cursor receiving empty results:
src/libbson/src/bson/bson-reader.c:526 bson_reader_new_from_data(): precondition failed: data
This applies when creating an exhaust cursor with the legacy op code OP_QUERY. The C driver uses OP_QUERY for exhaust cursor when connected to mongod < 4.2.
This appears to be a regression introduced in 1.24.0 as part of CDRIVER-4617.
Additional Information
Here is a regression test:
static void test_exhaust_cursor_no_match (void *context) { BSON_UNUSED (context); bson_error_t error; mongoc_client_t *client = test_framework_new_default_client (); mongoc_collection_t *coll = mongoc_client_get_collection (client, "db", "coll"); // Drop collection to remove prior test data. mongoc_collection_drop (coll, NULL /* ignore error */); mongoc_cursor_t *cursor = mongoc_collection_find_with_opts ( coll, tmp_bson ("{}"), tmp_bson ("{'exhaust': true }"), NULL /* read_prefs */); const bson_t *result; while (mongoc_cursor_next (cursor, &result)); // Assertion failure! mongoc_cursor_destroy (cursor); mongoc_collection_destroy (coll); mongoc_client_destroy (client); }
Here is a stack trace for the assert:
#0 bson_reader_new_from_data (data=0x0, length=0) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libbson/src/bson/bson-reader.c:526 #1 0x00005555558c1483 in _mongoc_cursor_op_query_find (cursor=0x5555560556b0, filter=0x555556096c78, response=0x555556096c40) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/src/mongoc/mongoc-cursor-legacy.c:587 #2 0x00005555558be264 in _prime (cursor=0x5555560556b0) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/src/mongoc/mongoc-cursor-find-opquery.c:49 #3 0x00005555558bdc79 in _prime (cursor=0x5555560556b0) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/src/mongoc/mongoc-cursor-find.c:57 #4 0x00005555558ba91f in _call_transition (cursor=0x5555560556b0) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/src/mongoc/mongoc-cursor.c:1145 #5 0x00005555558bab43 in mongoc_cursor_next (cursor=0x5555560556b0, bson=0x7fffffffd9e0) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/src/mongoc/mongoc-cursor.c:1221 #6 0x00005555556e7031 in test_exhaust_cursor_no_match (context=0x0) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/tests/test-mongoc-exhaust.c:364 #7 0x00005555557e867c in TestSuite_RunTest (suite=0x7fffffffdf80, test=0x555555efd2d0, count=0x7fffffffdf08) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/tests/TestSuite.c:611 #8 0x00005555557e98a7 in TestSuite_RunAll (suite=0x7fffffffdf80) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/tests/TestSuite.c:1046 #9 0x00005555557e99f4 in TestSuite_Run (suite=0x7fffffffdf80) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/tests/TestSuite.c:1091 #10 0x00005555555665ed in main (argc=4, argv=0x7fffffffe108) at /home/ubuntu/code/tasks/mongo-c-driver-cursor-crash/src/libmongoc/tests/test-libmongoc-main.c:157
- is caused by
-
CDRIVER-4617 Explore alternatives to X macros in mongoc-rpc.c
- Closed