[SERVER-12424] Certain $ projections can crash the server Created: 21/Jan/14  Updated: 11/Jul/16  Resolved: 24/Jan/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 2.5.5

Type: Bug Priority: Major - P3
Reporter: Andrew Emil (Inactive) Assignee: Benety Goh
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SERVER-12431 Positional projection on $or query ca... Closed
is duplicated by SERVER-12433 Positional projection on query with $... Closed
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Participants:

 Description   

Seems like certain $ projections will crash the server when run against current master. Note that there is no output indicating any issue in the mongod logs.

> db.test.find({$or: [{b: 1}]})
>
> db.test.find({$or: [{b: 1}]}, {"arrayField.$": 1})
2014-01-21T15:06:35.861-0800 DBClientCursor::init call() failed
Error: error doing query: failed
2014-01-21T15:06:35.863-0800 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2014-01-21T15:06:35.863-0800 warning: Failed to connect to 127.0.0.1:27017, reason: errno:61 Connection refused
2014-01-21T15:06:35.863-0800 reconnect 127.0.0.1:27017 (127.0.0.1) failed failed couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed



 Comments   
Comment by Githook User [ 24/Jan/14 ]

Author:

{u'username': u'benety', u'name': u'Benety Goh', u'email': u'benety@mongodb.com'}

Message: SERVER-12424 fixed pointer to deleted match expression issue in init().
Branch: master
https://github.com/mongodb/mongo/commit/c42f5d873c0a0b6622f04b9b4d0235e6f0ec5f9c

Comment by Andrew Emil (Inactive) [ 21/Jan/14 ]

Sorry about that, build from today on os x (git hash in log)

2014-01-21T15:18:11.560-0800 [initandlisten] MongoDB starting : pid=77754 port=27017 dbpath=/Users/ace/goodQA/data/data1/ 64-bit host=Andrew-Emil-MacBook-Pro.local
2014-01-21T15:18:11.560-0800 [initandlisten]
2014-01-21T15:18:11.560-0800 [initandlisten] ** NOTE: This is a development version (2.5.5-pre-) of MongoDB.
2014-01-21T15:18:11.560-0800 [initandlisten] **       Not recommended for production.
2014-01-21T15:18:11.560-0800 [initandlisten]
2014-01-21T15:18:11.560-0800 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2014-01-21T15:18:11.561-0800 [initandlisten]
2014-01-21T15:18:11.561-0800 [initandlisten] db version v2.5.5-pre-
2014-01-21T15:18:11.561-0800 [initandlisten] git version: f65a0b814b8c77e3fbe90bca0c061c9b77f6acdb
2014-01-21T15:18:11.561-0800 [initandlisten] build info: Darwin Andrew-Emil-MacBook-Pro.local 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2014-01-21T15:18:11.561-0800 [initandlisten] allocator: tcmalloc
2014-01-21T15:18:11.561-0800 [initandlisten] options: { logpath: "/Users/ace/goodQA/data/data1/log", processManagement: { fork: true }, storage: { dbPath: "/Users/ace/goodQA/data/data1/" } }
2014-01-21T15:18:11.563-0800 [initandlisten] journal dir=/Users/ace/goodQA/data/data1/journal
2014-01-21T15:18:11.563-0800 [initandlisten] recover begin
2014-01-21T15:18:11.564-0800 [initandlisten] recover lsn: 0
2014-01-21T15:18:11.564-0800 [initandlisten] recover /Users/ace/goodQA/data/data1/journal/j._0
2014-01-21T15:18:11.567-0800 [initandlisten] recover cleaning up
2014-01-21T15:18:11.567-0800 [initandlisten] removeJournalFiles
2014-01-21T15:18:11.567-0800 [initandlisten] recover done
2014-01-21T15:18:11.580-0800 [initandlisten] info openExisting file size 16777216 but storageGlobalParams.smallfiles=false: /Users/ace/goodQA/data/data1/local.0
2014-01-21T15:18:11.581-0800 [initandlisten]
2014-01-21T15:18:11.581-0800 [initandlisten] ** WARNING: mongod started without --replSet yet 1 documents are present in local.system.replset
2014-01-21T15:18:11.581-0800 [initandlisten] **          Restart with --replSet unless you are doing maintenance and no other clients are connected.
2014-01-21T15:18:11.581-0800 [initandlisten] **          The TTL collection monitor will not start because of this.
2014-01-21T15:18:11.581-0800 [initandlisten] **          For more info see http://dochub.mongodb.org/core/ttlcollections
2014-01-21T15:18:11.581-0800 [initandlisten]
2014-01-21T15:18:11.583-0800 [initandlisten] info openExisting file size 16777216 but storageGlobalParams.smallfiles=false: /Users/ace/goodQA/data/data1/config.0
2014-01-21T15:18:11.589-0800 [IndexRebuilder] info openExisting file size 16777216 but storageGlobalParams.smallfiles=false: /Users/ace/goodQA/data/data1/config.0
2014-01-21T15:18:11.591-0800 [initandlisten] info openExisting file size 16777216 but storageGlobalParams.smallfiles=false: /Users/ace/goodQA/data/data1/local.0
2014-01-21T15:18:11.593-0800 [initandlisten] waiting for connections on port 27017
2014-01-21T15:18:14.648-0800 [initandlisten] connection accepted from 127.0.0.1:60104 #1 (1 connection now open)

Comment by Scott Hernandez (Inactive) [ 21/Jan/14 ]

Andrew, please provide the server output and version (git hash) when you file these:

My build was from master today, on osx.

2014-01-21T18:15:16.822-0500 [initandlisten] MongoDB starting : pid=4552 port=27017 dbpath=/Users/skot/data/temp/ 64-bit host=pans-2.local
2014-01-21T18:15:16.822-0500 [initandlisten] 
2014-01-21T18:15:16.822-0500 [initandlisten] ** NOTE: This is a development version (2.5.5-pre-) of MongoDB.
2014-01-21T18:15:16.822-0500 [initandlisten] **       Not recommended for production.
2014-01-21T18:15:16.822-0500 [initandlisten] 
2014-01-21T18:15:16.822-0500 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
2014-01-21T18:15:16.822-0500 [initandlisten] 
2014-01-21T18:15:16.822-0500 [initandlisten] db version v2.5.5-pre-
2014-01-21T18:15:16.822-0500 [initandlisten] git version: 320397d71a0344db775146e42a54d755241533b2
2014-01-21T18:15:16.822-0500 [initandlisten] build info: Darwin pans-2.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
2014-01-21T18:15:16.822-0500 [initandlisten] allocator: tcmalloc
2014-01-21T18:15:16.822-0500 [initandlisten] options: { enableExperimentalIndexStatsCmd: true, enableExperimentalStorageDetailsCmd: true, httpinterface: true, net: { http: { JSONPEnabled: true, RESTInterfaceEnabled: true } }, nojournal: true, replication: { replSet: "test1" }, setParameter: { enableTestCommands: "1" }, storage: { dbPath: "/Users/skot/data/temp/" } }
2014-01-21T18:15:16.988-0500 [initandlisten] WARNING: the collection 'test.no_id' lacks a unique index on _id. This index is needed for replication to function properly
2014-01-21T18:15:16.988-0500 [initandlisten] 	 To fix this, on the primary run 'db.no_id.createIndex({_id: 1}, {unique: true})'
2014-01-21T18:15:16.988-0500 [initandlisten] WARNING: the collection 'test.foo2' lacks a unique index on _id. This index is needed for replication to function properly
2014-01-21T18:15:16.988-0500 [initandlisten] 	 To fix this, on the primary run 'db.foo2.createIndex({_id: 1}, {unique: true})'
2014-01-21T18:15:16.988-0500 [initandlisten] WARNING: the collection 'test.no_id_index' lacks a unique index on _id. This index is needed for replication to function properly
2014-01-21T18:15:16.988-0500 [initandlisten] 	 To fix this, on the primary run 'db.no_id_index.createIndex({_id: 1}, {unique: true})'
2014-01-21T18:15:17.015-0500 [initandlisten] waiting for connections on port 27017
2014-01-21T18:15:17.015-0500 [websvr] admin web console waiting for connections on port 28017
2014-01-21T18:15:17.016-0500 [rsStart] replSet I am localhost:27017
2014-01-21T18:15:17.206-0500 [rsStart] replSet STARTUP2
2014-01-21T18:15:17.206-0500 [rsSync] replSet SECONDARY
2014-01-21T18:15:17.206-0500 [rsMgr] replSet info electSelf 0
2014-01-21T18:15:18.207-0500 [rsMgr] replSet PRIMARY
2014-01-21T18:15:21.310-0500 [initandlisten] connection accepted from 127.0.0.1:56548 #1 (1 connection now open)
Invalid access at address: 0x10 from thread: conn1
Got signal: 11 (Segmentation fault: 11).
Backtrace:
0x1007297b0 0x100007866 0x100007bbe 0x7fff8f9355aa 0x1 0x10040af95 0x1003eabee 0x1003ea959 0x100407e8e 0x1002bce5b 0x10000f537 0x1006e4d91 0x100763591 0x7fff8b347899 0x7fff8b34772a 0x7fff8b34bfc9 
 0   mongod                              0x00000001007297b0 _ZN5mongo15printStackTraceERSo + 64
 1   mongod                              0x0000000100007866 _ZN5mongo10abruptQuitEi + 422
 2   mongod                              0x0000000100007bbe _ZN5mongo24abruptQuitWithAddrSignalEiP9__siginfoPv + 334
 3   libsystem_platform.dylib            0x00007fff8f9355aa _sigtramp + 26
 4   ???                                 0x0000000000000001 0x0 + 1
 5   mongod                              0x000000010040af95 _ZN5mongo16ParsedProjection4makeERKNS_7BSONObjEPKNS_15MatchExpressionEPPS0_ + 1269
 6   mongod                              0x00000001003eabee _ZN5mongo14CanonicalQuery4initEPNS_15LiteParsedQueryE + 286
 7   mongod                              0x00000001003ea959 _ZN5mongo14CanonicalQuery12canonicalizeERKNS_12QueryMessageEPPS0_ + 137
 8   mongod                              0x0000000100407e8e _ZN5mongo11newRunQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 1358
 9   mongod                              0x00000001002bce5b _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 1659
 10  mongod                              0x000000010000f537 _ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE + 183
 11  mongod                              0x00000001006e4d91 _ZN5mongo17PortMessageServer17handleIncomingMsgEPv + 913
 12  mongod                              0x0000000100763591 thread_proxy + 177
 13  libsystem_pthread.dylib             0x00007fff8b347899 _pthread_body + 138
 14  libsystem_pthread.dylib             0x00007fff8b34772a _pthread_struct_init + 0
 15  libsystem_pthread.dylib             0x00007fff8b34bfc9 thread_start + 13

Generated at Thu Feb 08 03:28:30 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.