Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-30925

Segfault merging aggregation sort on mongos with array keys

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.13
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • ALL
    • Hide
      // Set up a cluster with two shards.
      let st = new ShardingTest({shards: 2});
      let testDB = st.getDB("test");
      assert.commandWorked(st.s0.adminCommand({enableSharding: testDB.getName()}));
      assert.commandWorked(st.s0.adminCommand({shardCollection: "test.coll", key: {_id: 1}}));
      
      // Put some data on each shard.
      assert.commandWorked(st.s0.adminCommand({split: "test.coll", middle: {_id: 1}}));
      assert.commandWorked(st.s0.adminCommand({
          movechunk: "test.coll",
          find: {_id: 0},
          to: st.getOther(st.getPrimaryShard("test")).name
      }));
      assert.writeOK(testDB.coll.insert({_id: 0, x: [0]}));
      assert.writeOK(testDB.coll.insert({_id: 2, x: [0]}));
          
      // Run an aggregation that merges sorted results with array sort keys on the mongos.
      // Crashes.
      testDB.coll.aggregate([{$sort: {x: 1}}]);
      

      Stacktrace:

      [js_test:repro] 2017-09-01T15:17:17.983-0400 s20015| 2017-09-01T15:17:17.983-0400 F -        [conn1] Invalid access at address: 0
      [js_test:repro] 2017-09-01T15:17:18.007-0400 s20015| 2017-09-01T15:17:18.006-0400 F -        [conn1] Got signal: 11 (Segmentation fault).
      [js_test:repro] 2017-09-01T15:17:18.007-0400 s20015|
      [js_test:repro] 2017-09-01T15:17:18.007-0400 s20015|  0x55d2e53306a1 0x55d2e532f8b9 0x55d2e532ff26 0x7fb5c1709d10 0x55d2e4d8c484 0x55d2e4d8c6fa 0x55d2e4c44e87 0x55d2e4c45268 0x55d2e4c488b7 0x55d2e4c49bc1 0x55d2e4c4698c 0x55d2e4c46ab4 0x55d2e4c46cfc 0x55d2e4bc7bad 0x55d2e495b0e2 0x55d2e4958809 0x55d2e47b8121 0x55d2e489d151 0x55d2e48f9515 0x55d2e48f98b4 0x55d2e4cf8a86 0x55d2e4cf55cf 0x55d2e492aa25 0x55d2e492b8e4 0x55d2e492c209 0x55d2e483f6f1 0x55d2e4858f90 0x55d2e4855f85 0x55d2e48580b7 0x55d2e48538a1 0x55d2e51f4054 0x7fb5c17006aa 0x7fb5c1435eed
      [js_test:repro] 2017-09-01T15:17:18.007-0400 s20015| ----- BEGIN BACKTRACE -----
      [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015| {"backtrace":[{"b":"55D2E43A0000","o":"F906A1","s":"_ZN5mongo15printStackTraceERSo"},{"b":"55D2E43A0000","o":"F8F8B9"},{"b":"55D2E43A0000","o":"F8FF26"},{"b":"7FB5C16F9000","o":"10D10"},{"b":"55D2E43A0000","o":"9EC484","s":"_ZNK5mongo16SortKeyGenerator11getIndexKeyERKNS_7BSONObjE"},{"b":"55D2E43A0000","o":"9EC6FA","s":"_ZNK5mongo16SortKeyGenerator10getSortKeyERKNS_7BSONObjEPKNS0_8MetadataE"},{"b":"55D2E43A0000","o":"8A4E87","s":"_ZNK5mongo18DocumentSourceSort19extractKeyWithArrayERKNS_8DocumentE"},{"b":"55D2E43A0000","o":"8A5268","s":"_ZNK5mongo18DocumentSourceSort10extractKeyERKNS_8DocumentE"},{"b":"55D2E43A0000","o":"8A88B7","s":"_ZN5mongo18DocumentSourceSort18IteratorFromCursor4nextEv"},{"b":"55D2E43A0000","o":"8A9BC1","s":"_ZN5mongo21SortIteratorInterfaceINS_5ValueENS_8DocumentEE5mergeINS_18DocumentSourceSort10ComparatorEEEPS3_RKSt6vectorISt10shared_ptrIS3_ESaISA_EERKNS_11SortOptionsERKT_"},{"b":"55D2E43A0000","o":"8A698C","s":"_ZN5mongo18DocumentSourceSort19populateFromCursorsERKSt6vectorIPNS_14DBClientCursorESaIS3_EE"},{"b":"55D2E43A0000","o":"8A6AB4","s":"_ZN5mongo18DocumentSourceSort8populateEv"},{"b":"55D2E43A0000","o":"8A6CFC","s":"_ZN5mongo18DocumentSourceSort7getNextEv"},{"b":"55D2E43A0000","o":"827BAD","s":"_ZN5mongo8Pipeline7getNextEv"},{"b":"55D2E43A0000","o":"5BB0E2","s":"_ZN5mongo27RouterStageAggregationMerge4nextEv"},{"b":"55D2E43A0000","o":"5B8809","s":"_ZN5mongo23ClusterClientCursorImpl4nextEv"},{"b":"55D2E43A0000","o":"418121"},{"b":"55D2E43A0000","o":"4FD151","s":"_ZN5mongo16ClusterAggregate12runAggregateEPNS_16OperationContextERKNS0_10NamespacesERKNS_18AggregationRequestENS_7BSONObjEPNS_14BSONObjBuilderE"},{"b":"55D2E43A0000","o":"559515"},{"b":"55D2E43A0000","o":"5598B4"},{"b":"55D2E43A0000","o":"958A86","s":"_ZN5mongo12BasicCommand11enhancedRunEPNS_16OperationContextERKNS_12OpMsgRequestERNS_14BSONObjBuilderE"},{"b":"55D2E43A0000","o":"9555CF","s":"_ZN5mongo7Command9publicRunEPNS_16OperationContextERKNS_12OpMsgRequestERNS_14BSONObjBuilderE"},{"b":"55D2E43A0000","o":"58AA25"},{"b":"55D2E43A0000","o":"58B8E4"},{"b":"55D2E43A0000","o":"58C209","s":"_ZN5mongo8Strategy13clientCommandEPNS_16OperationContextERKNS_7MessageE"},{"b":"55D2E43A0000","o":"49F6F1","s":"_ZN5mongo23ServiceEntryPointMongos13handleRequestEPNS_16OperationContextERKNS_7MessageE"},{"b":"55D2E43A0000","o":"4B8F90","s":"_ZN5mongo19ServiceStateMachine15_processMessageERNS0_11ThreadGuardE"},{"b":"55D2E43A0000","o":"4B5F85","s":"_ZN5mongo19ServiceStateMachine15_runNextInGuardERNS0_11ThreadGuardE"},{"b":"55D2E43A0000","o":"4B80B7","s":"_ZN5mongo19ServiceStateMachine7runNextEv"},{"b":"55D2E43A0000","o":"4B38A1"},{"b":"55D2E43A0000","o":"E54054"},{"b":"7FB5C16F9000","o":"76AA"},{"b":"7FB5C132F000","o":"106EED","s":"clone"}],"processInfo":{ "mongodbVersion" : "3.5.12-132-g144cb2c", "gitVersion" : "144cb2c717d2d58b7503eab7fa15f28f95772bcc", "compiledModules" : [], "uname" : { "sysname" : "Linux", "release" : "4.2.0-16-generic", "version" : "#19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015", "machine" : "x86_64" }, "somap" : [ { "b" : "55D2E43A0000", "elfType" : 3, "buildId" : "68CCD3374D966C651B261BB7D127C870CC7C9A88" }, { "b" : "7FFFE2BC7000", "elfType" : 3, "buildId" : "BC784BEAA199A23C0D47D6AC888C3DAEA5EEAA0C" }, { "b" : "7FB5C203A000", "path" : "/lib/x86_64-linux-gnu/librt.so.1", "elfType" : 3, "buildId" : "CB26CB6169CBAA9DA2E38A70BCF7D57A8047CCF3" }, { "b" : "7FB5C1E36000", "path" : "/lib/x86_64-linux-gnu/libdl.so.2", "elfType" : 3, "buildId" : "F974B99C0C327670EF882BA13912E995A12C6402" }, { "b" : "7FB5C1B2E000", "path" : "/lib/x86_64-linux-gnu/libm.so.6", "elfType" : 3, "buildId" : "372ADD7EB11B9D51E634BC91DAAA58DF90567FD1" }, { "b" : "7FB5C1917000", "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1", "elfType" : 3, "buildId" : "0C3C07EE15CFA81346847A679E8444B876D9CC58" }, { "b" : "7FB5C16F9000", "path" : "/lib/x86_64-linux-gnu/libpthread.so.0", "elfType" : 3, "buildId" : "A37A144BCBEE86A9E02DFF5021A111EDE6A1F212" }, { "b" : "7FB5C132F000", "path" : "/lib/x86_64-linux-gnu/libc.so.6", "elfType" : 3, "buildId" : "8ACD43CF74A9756CD727B8516B08679EE071A92D" }, { "b" : "7FB5C2242000", "path" : "/lib64/ld-linux-x86-64.so.2", "elfType" : 3, "buildId" : "903BB7A6DEEFD966DCEEC4566C70444C727ED294" }, { "b" : "7FB5C1122000", "path" : "/lib/x86_64-linux-gnu/libnss_files.so.2", "elfType" : 3, "buildId" : "F5CE64204F5C11B4421982A1B74FE9781498C5F5" } ] }}
      [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015|  mongos(_ZN5mongo15printStackTraceERSo+0x41) [0x55d2e53306a1]
      [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015|  mongos(+0xF8F8B9) [0x55d2e532f8b9]
      [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015|  mongos(+0xF8FF26) [0x55d2e532ff26]
      [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015|  libpthread.so.0(+0x10D10) [0x7fb5c1709d10]
      [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015|  mongos(_ZNK5mongo16SortKeyGenerator11getIndexKeyERKNS_7BSONObjE+0x24) [0x55d2e4d8c484]
      [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015|  mongos(_ZNK5mongo16SortKeyGenerator10getSortKeyERKNS_7BSONObjEPKNS0_8MetadataE+0x4A) [0x55d2e4d8c6fa]
      [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015|  mongos(_ZNK5mongo18DocumentSourceSort19extractKeyWithArrayERKNS_8DocumentE+0xB7) [0x55d2e4c44e87]
      [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015|  mongos(_ZNK5mongo18DocumentSourceSort10extractKeyERKNS_8DocumentE+0x48) [0x55d2e4c45268]
      [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015|  mongos(_ZN5mongo18DocumentSourceSort18IteratorFromCursor4nextEv+0x47) [0x55d2e4c488b7]
      [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015|  mongos(_ZN5mongo21SortIteratorInterfaceINS_5ValueENS_8DocumentEE5mergeINS_18DocumentSourceSort10ComparatorEEEPS3_RKSt6vectorISt10shared_ptrIS3_ESaISA_EERKNS_11SortOptionsERKT_+0x131) [0x55d2e4c49bc1]
      [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015|  mongos(_ZN5mongo18DocumentSourceSort19populateFromCursorsERKSt6vectorIPNS_14DBClientCursorESaIS3_EE+0x1CC) [0x55d2e4c4698c]
      [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015|  mongos(_ZN5mongo18DocumentSourceSort8populateEv+0x74) [0x55d2e4c46ab4]
      [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015|  mongos(_ZN5mongo18DocumentSourceSort7getNextEv+0xDC) [0x55d2e4c46cfc]
      [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015|  mongos(_ZN5mongo8Pipeline7getNextEv+0x3D) [0x55d2e4bc7bad]
      [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015|  mongos(_ZN5mongo27RouterStageAggregationMerge4nextEv+0x32) [0x55d2e495b0e2]
      [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015|  mongos(_ZN5mongo23ClusterClientCursorImpl4nextEv+0x179) [0x55d2e4958809]
      [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015|  mongos(+0x418121) [0x55d2e47b8121]
      [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015|  mongos(_ZN5mongo16ClusterAggregate12runAggregateEPNS_16OperationContextERKNS0_10NamespacesERKNS_18AggregationRequestENS_7BSONObjEPNS_14BSONObjBuilderE+0x3901) [0x55d2e489d151]
      [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015|  mongos(+0x559515) [0x55d2e48f9515]
      [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015|  mongos(+0x5598B4) [0x55d2e48f98b4]
      [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015|  mongos(_ZN5mongo12BasicCommand11enhancedRunEPNS_16OperationContextERKNS_12OpMsgRequestERNS_14BSONObjBuilderE+0x76) [0x55d2e4cf8a86]
      [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015|  mongos(_ZN5mongo7Command9publicRunEPNS_16OperationContextERKNS_12OpMsgRequestERNS_14BSONObjBuilderE+0x1F) [0x55d2e4cf55cf]
      [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015|  mongos(+0x58AA25) [0x55d2e492aa25]
      [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015|  mongos(+0x58B8E4) [0x55d2e492b8e4]
      [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015|  mongos(_ZN5mongo8Strategy13clientCommandEPNS_16OperationContextERKNS_7MessageE+0x59) [0x55d2e492c209]
      [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015|  mongos(_ZN5mongo23ServiceEntryPointMongos13handleRequestEPNS_16OperationContextERKNS_7MessageE+0x5A1) [0x55d2e483f6f1]
      [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015|  mongos(_ZN5mongo19ServiceStateMachine15_processMessageERNS0_11ThreadGuardE+0xF0) [0x55d2e4858f90]
      [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015|  mongos(_ZN5mongo19ServiceStateMachine15_runNextInGuardERNS0_11ThreadGuardE+0x1B5) [0x55d2e4855f85]
      [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015|  mongos(_ZN5mongo19ServiceStateMachine7runNextEv+0x157) [0x55d2e48580b7]
      [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015|  mongos(+0x4B38A1) [0x55d2e48538a1]
      [js_test:repro] 2017-09-01T15:17:18.015-0400 s20015|  mongos(+0xE54054) [0x55d2e51f4054]
      [js_test:repro] 2017-09-01T15:17:18.015-0400 s20015|  libpthread.so.0(+0x76AA) [0x7fb5c17006aa]
      [js_test:repro] 2017-09-01T15:17:18.015-0400 s20015|  libc.so.6(clone+0x6D) [0x7fb5c1435eed]
      [js_test:repro] 2017-09-01T15:17:18.015-0400 s20015| -----  END BACKTRACE  -----
      

      ASAN output:

      [js_test:agg_sort] 2017-09-01T18:03:26.222+0000 s21015| mongos: src/third_party/boost-1.60.0/boost/optional/optional.hpp:1034: pointer_const_type boost::optional<mongo::SortKeyGenerator>::operator->() const [T = mongo::SortKeyGenerator]: Assertion `this->is_initialized()' failed.
      
      Show
      // Set up a cluster with two shards. let st = new ShardingTest({shards: 2}); let testDB = st.getDB( "test" ); assert .commandWorked(st.s0.adminCommand({enableSharding: testDB.getName()})); assert .commandWorked(st.s0.adminCommand({shardCollection: "test.coll" , key: {_id: 1}})); // Put some data on each shard. assert .commandWorked(st.s0.adminCommand({split: "test.coll" , middle: {_id: 1}})); assert .commandWorked(st.s0.adminCommand({ movechunk: "test.coll" , find: {_id: 0}, to: st.getOther(st.getPrimaryShard( "test" )).name })); assert .writeOK(testDB.coll.insert({_id: 0, x: [0]})); assert .writeOK(testDB.coll.insert({_id: 2, x: [0]})); // Run an aggregation that merges sorted results with array sort keys on the mongos. // Crashes. testDB.coll.aggregate([{$sort: {x: 1}}]); Stacktrace: [js_test:repro] 2017-09-01T15:17:17.983-0400 s20015| 2017-09-01T15:17:17.983-0400 F - [conn1] Invalid access at address: 0 [js_test:repro] 2017-09-01T15:17:18.007-0400 s20015| 2017-09-01T15:17:18.006-0400 F - [conn1] Got signal: 11 (Segmentation fault). [js_test:repro] 2017-09-01T15:17:18.007-0400 s20015| [js_test:repro] 2017-09-01T15:17:18.007-0400 s20015| 0x55d2e53306a1 0x55d2e532f8b9 0x55d2e532ff26 0x7fb5c1709d10 0x55d2e4d8c484 0x55d2e4d8c6fa 0x55d2e4c44e87 0x55d2e4c45268 0x55d2e4c488b7 0x55d2e4c49bc1 0x55d2e4c4698c 0x55d2e4c46ab4 0x55d2e4c46cfc 0x55d2e4bc7bad 0x55d2e495b0e2 0x55d2e4958809 0x55d2e47b8121 0x55d2e489d151 0x55d2e48f9515 0x55d2e48f98b4 0x55d2e4cf8a86 0x55d2e4cf55cf 0x55d2e492aa25 0x55d2e492b8e4 0x55d2e492c209 0x55d2e483f6f1 0x55d2e4858f90 0x55d2e4855f85 0x55d2e48580b7 0x55d2e48538a1 0x55d2e51f4054 0x7fb5c17006aa 0x7fb5c1435eed [js_test:repro] 2017-09-01T15:17:18.007-0400 s20015| ----- BEGIN BACKTRACE ----- [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015| { "backtrace" :[{ "b" : "55D2E43A0000" , "o" : "F906A1" , "s" : "_ZN5mongo15printStackTraceERSo" },{ "b" : "55D2E43A0000" , "o" : "F8F8B9" },{ "b" : "55D2E43A0000" , "o" : "F8FF26" },{ "b" : "7FB5C16F9000" , "o" : "10D10" },{ "b" : "55D2E43A0000" , "o" : "9EC484" , "s" : "_ZNK5mongo16SortKeyGenerator11getIndexKeyERKNS_7BSONObjE" },{ "b" : "55D2E43A0000" , "o" : "9EC6FA" , "s" : "_ZNK5mongo16SortKeyGenerator10getSortKeyERKNS_7BSONObjEPKNS0_8MetadataE" },{ "b" : "55D2E43A0000" , "o" : "8A4E87" , "s" : "_ZNK5mongo18DocumentSourceSort19extractKeyWithArrayERKNS_8DocumentE" },{ "b" : "55D2E43A0000" , "o" : "8A5268" , "s" : "_ZNK5mongo18DocumentSourceSort10extractKeyERKNS_8DocumentE" },{ "b" : "55D2E43A0000" , "o" : "8A88B7" , "s" : "_ZN5mongo18DocumentSourceSort18IteratorFromCursor4nextEv" },{ "b" : "55D2E43A0000" , "o" : "8A9BC1" , "s" : "_ZN5mongo21SortIteratorInterfaceINS_5ValueENS_8DocumentEE5mergeINS_18DocumentSourceSort10ComparatorEEEPS3_RKSt6vectorISt10shared_ptrIS3_ESaISA_EERKNS_11SortOptionsERKT_" },{ "b" : "55D2E43A0000" , "o" : "8A698C" , "s" : "_ZN5mongo18DocumentSourceSort19populateFromCursorsERKSt6vectorIPNS_14DBClientCursorESaIS3_EE" },{ "b" : "55D2E43A0000" , "o" : "8A6AB4" , "s" : "_ZN5mongo18DocumentSourceSort8populateEv" },{ "b" : "55D2E43A0000" , "o" : "8A6CFC" , "s" : "_ZN5mongo18DocumentSourceSort7getNextEv" },{ "b" : "55D2E43A0000" , "o" : "827BAD" , "s" : "_ZN5mongo8Pipeline7getNextEv" },{ "b" : "55D2E43A0000" , "o" : "5BB0E2" , "s" : "_ZN5mongo27RouterStageAggregationMerge4nextEv" },{ "b" : "55D2E43A0000" , "o" : "5B8809" , "s" : "_ZN5mongo23ClusterClientCursorImpl4nextEv" },{ "b" : "55D2E43A0000" , "o" : "418121" },{ "b" : "55D2E43A0000" , "o" : "4FD151" , "s" : "_ZN5mongo16ClusterAggregate12runAggregateEPNS_16OperationContextERKNS0_10NamespacesERKNS_18AggregationRequestENS_7BSONObjEPNS_14BSONObjBuilderE" },{ "b" : "55D2E43A0000" , "o" : "559515" },{ "b" : "55D2E43A0000" , "o" : "5598B4" },{ "b" : "55D2E43A0000" , "o" : "958A86" , "s" : "_ZN5mongo12BasicCommand11enhancedRunEPNS_16OperationContextERKNS_12OpMsgRequestERNS_14BSONObjBuilderE" },{ "b" : "55D2E43A0000" , "o" : "9555CF" , "s" : "_ZN5mongo7Command9publicRunEPNS_16OperationContextERKNS_12OpMsgRequestERNS_14BSONObjBuilderE" },{ "b" : "55D2E43A0000" , "o" : "58AA25" },{ "b" : "55D2E43A0000" , "o" : "58B8E4" },{ "b" : "55D2E43A0000" , "o" : "58C209" , "s" : "_ZN5mongo8Strategy13clientCommandEPNS_16OperationContextERKNS_7MessageE" },{ "b" : "55D2E43A0000" , "o" : "49F6F1" , "s" : "_ZN5mongo23ServiceEntryPointMongos13handleRequestEPNS_16OperationContextERKNS_7MessageE" },{ "b" : "55D2E43A0000" , "o" : "4B8F90" , "s" : "_ZN5mongo19ServiceStateMachine15_processMessageERNS0_11ThreadGuardE" },{ "b" : "55D2E43A0000" , "o" : "4B5F85" , "s" : "_ZN5mongo19ServiceStateMachine15_runNextInGuardERNS0_11ThreadGuardE" },{ "b" : "55D2E43A0000" , "o" : "4B80B7" , "s" : "_ZN5mongo19ServiceStateMachine7runNextEv" },{ "b" : "55D2E43A0000" , "o" : "4B38A1" },{ "b" : "55D2E43A0000" , "o" : "E54054" },{ "b" : "7FB5C16F9000" , "o" : "76AA" },{ "b" : "7FB5C132F000" , "o" : "106EED" , "s" : "clone" }], "processInfo" :{ "mongodbVersion" : "3.5.12-132-g144cb2c" , "gitVersion" : "144cb2c717d2d58b7503eab7fa15f28f95772bcc" , "compiledModules" : [], "uname" : { "sysname" : "Linux" , "release" : "4.2.0-16- generic " , "version" : "#19-Ubuntu SMP Thu Oct 8 15:35:06 UTC 2015" , "machine" : "x86_64" }, "somap" : [ { "b" : "55D2E43A0000" , "elfType" : 3, "buildId" : "68CCD3374D966C651B261BB7D127C870CC7C9A88" }, { "b" : "7FFFE2BC7000" , "elfType" : 3, "buildId" : "BC784BEAA199A23C0D47D6AC888C3DAEA5EEAA0C" }, { "b" : "7FB5C203A000" , "path" : "/lib/x86_64-linux-gnu/librt.so.1" , "elfType" : 3, "buildId" : "CB26CB6169CBAA9DA2E38A70BCF7D57A8047CCF3" }, { "b" : "7FB5C1E36000" , "path" : "/lib/x86_64-linux-gnu/libdl.so.2" , "elfType" : 3, "buildId" : "F974B99C0C327670EF882BA13912E995A12C6402" }, { "b" : "7FB5C1B2E000" , "path" : "/lib/x86_64-linux-gnu/libm.so.6" , "elfType" : 3, "buildId" : "372ADD7EB11B9D51E634BC91DAAA58DF90567FD1" }, { "b" : "7FB5C1917000" , "path" : "/lib/x86_64-linux-gnu/libgcc_s.so.1" , "elfType" : 3, "buildId" : "0C3C07EE15CFA81346847A679E8444B876D9CC58" }, { "b" : "7FB5C16F9000" , "path" : "/lib/x86_64-linux-gnu/libpthread.so.0" , "elfType" : 3, "buildId" : "A37A144BCBEE86A9E02DFF5021A111EDE6A1F212" }, { "b" : "7FB5C132F000" , "path" : "/lib/x86_64-linux-gnu/libc.so.6" , "elfType" : 3, "buildId" : "8ACD43CF74A9756CD727B8516B08679EE071A92D" }, { "b" : "7FB5C2242000" , "path" : "/lib64/ld-linux-x86-64.so.2" , "elfType" : 3, "buildId" : "903BB7A6DEEFD966DCEEC4566C70444C727ED294" }, { "b" : "7FB5C1122000" , "path" : "/lib/x86_64-linux-gnu/libnss_files.so.2" , "elfType" : 3, "buildId" : "F5CE64204F5C11B4421982A1B74FE9781498C5F5" } ] }} [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015| mongos(_ZN5mongo15printStackTraceERSo+0x41) [0x55d2e53306a1] [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015| mongos(+0xF8F8B9) [0x55d2e532f8b9] [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015| mongos(+0xF8FF26) [0x55d2e532ff26] [js_test:repro] 2017-09-01T15:17:18.010-0400 s20015| libpthread.so.0(+0x10D10) [0x7fb5c1709d10] [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015| mongos(_ZNK5mongo16SortKeyGenerator11getIndexKeyERKNS_7BSONObjE+0x24) [0x55d2e4d8c484] [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015| mongos(_ZNK5mongo16SortKeyGenerator10getSortKeyERKNS_7BSONObjEPKNS0_8MetadataE+0x4A) [0x55d2e4d8c6fa] [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015| mongos(_ZNK5mongo18DocumentSourceSort19extractKeyWithArrayERKNS_8DocumentE+0xB7) [0x55d2e4c44e87] [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015| mongos(_ZNK5mongo18DocumentSourceSort10extractKeyERKNS_8DocumentE+0x48) [0x55d2e4c45268] [js_test:repro] 2017-09-01T15:17:18.011-0400 s20015| mongos(_ZN5mongo18DocumentSourceSort18IteratorFromCursor4nextEv+0x47) [0x55d2e4c488b7] [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015| mongos(_ZN5mongo21SortIteratorInterfaceINS_5ValueENS_8DocumentEE5mergeINS_18DocumentSourceSort10ComparatorEEEPS3_RKSt6vectorISt10shared_ptrIS3_ESaISA_EERKNS_11SortOptionsERKT_+0x131) [0x55d2e4c49bc1] [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015| mongos(_ZN5mongo18DocumentSourceSort19populateFromCursorsERKSt6vectorIPNS_14DBClientCursorESaIS3_EE+0x1CC) [0x55d2e4c4698c] [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015| mongos(_ZN5mongo18DocumentSourceSort8populateEv+0x74) [0x55d2e4c46ab4] [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015| mongos(_ZN5mongo18DocumentSourceSort7getNextEv+0xDC) [0x55d2e4c46cfc] [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015| mongos(_ZN5mongo8Pipeline7getNextEv+0x3D) [0x55d2e4bc7bad] [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015| mongos(_ZN5mongo27RouterStageAggregationMerge4nextEv+0x32) [0x55d2e495b0e2] [js_test:repro] 2017-09-01T15:17:18.012-0400 s20015| mongos(_ZN5mongo23ClusterClientCursorImpl4nextEv+0x179) [0x55d2e4958809] [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015| mongos(+0x418121) [0x55d2e47b8121] [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015| mongos(_ZN5mongo16ClusterAggregate12runAggregateEPNS_16OperationContextERKNS0_10NamespacesERKNS_18AggregationRequestENS_7BSONObjEPNS_14BSONObjBuilderE+0x3901) [0x55d2e489d151] [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015| mongos(+0x559515) [0x55d2e48f9515] [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015| mongos(+0x5598B4) [0x55d2e48f98b4] [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015| mongos(_ZN5mongo12BasicCommand11enhancedRunEPNS_16OperationContextERKNS_12OpMsgRequestERNS_14BSONObjBuilderE+0x76) [0x55d2e4cf8a86] [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015| mongos(_ZN5mongo7Command9publicRunEPNS_16OperationContextERKNS_12OpMsgRequestERNS_14BSONObjBuilderE+0x1F) [0x55d2e4cf55cf] [js_test:repro] 2017-09-01T15:17:18.013-0400 s20015| mongos(+0x58AA25) [0x55d2e492aa25] [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015| mongos(+0x58B8E4) [0x55d2e492b8e4] [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015| mongos(_ZN5mongo8Strategy13clientCommandEPNS_16OperationContextERKNS_7MessageE+0x59) [0x55d2e492c209] [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015| mongos(_ZN5mongo23ServiceEntryPointMongos13handleRequestEPNS_16OperationContextERKNS_7MessageE+0x5A1) [0x55d2e483f6f1] [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015| mongos(_ZN5mongo19ServiceStateMachine15_processMessageERNS0_11ThreadGuardE+0xF0) [0x55d2e4858f90] [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015| mongos(_ZN5mongo19ServiceStateMachine15_runNextInGuardERNS0_11ThreadGuardE+0x1B5) [0x55d2e4855f85] [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015| mongos(_ZN5mongo19ServiceStateMachine7runNextEv+0x157) [0x55d2e48580b7] [js_test:repro] 2017-09-01T15:17:18.014-0400 s20015| mongos(+0x4B38A1) [0x55d2e48538a1] [js_test:repro] 2017-09-01T15:17:18.015-0400 s20015| mongos(+0xE54054) [0x55d2e51f4054] [js_test:repro] 2017-09-01T15:17:18.015-0400 s20015| libpthread.so.0(+0x76AA) [0x7fb5c17006aa] [js_test:repro] 2017-09-01T15:17:18.015-0400 s20015| libc.so.6(clone+0x6D) [0x7fb5c1435eed] [js_test:repro] 2017-09-01T15:17:18.015-0400 s20015| ----- END BACKTRACE ----- ASAN output: [js_test:agg_sort] 2017-09-01T18:03:26.222+0000 s21015| mongos: src/third_party/boost-1.60.0/boost/optional/optional.hpp:1034: pointer_const_type boost::optional<mongo::SortKeyGenerator>:: operator ->() const [T = mongo::SortKeyGenerator]: Assertion ` this ->is_initialized()' failed.
    • Query 2017-09-11

      DocumentSourceSort::getMergeSource() does not populate the returned DocumentSourceSort with _paths or _sortKeyGen, both of which are required for sorting arrays in extractKeyWithArray(). This leads to undefined behavior when merging sorted results with array keys on mongos. We should change DocumentSourceSort::getMergeSource() to fully clone this, then set _mergingPresorted to true.

            Assignee:
            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            Reporter:
            tess.avitabile@mongodb.com Tess Avitabile (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: