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

Segmentation fault running query with $where

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.10
    • Component/s: JavaScript
    • Labels:
      None
    • ALL
    • Hide
      $mongo
      MongoDB shell version: 2.6.10
      connecting to: test
      Server has startup warnings: 
      2015-07-01T12:41:47.230-0700 ** WARNING: --rest is specified without --httpinterface,
      2015-07-01T12:41:47.230-0700 **          enabling http interface
      > db.version()
      2.6.10
      > version()
      2.6.10
      > > db.test.find( { $where: "this.credits == this.debits" } )
      2015-07-01T12:36:12.748-0700 DBClientCursor::init call() failed
      Error: error doing query: failed
      2015-07-01T12:36:12.750-0700 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
      2015-07-01T12:36:12.751-0700 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
      ...
      
      Show
      $mongo MongoDB shell version: 2.6.10 connecting to: test Server has startup warnings: 2015-07-01T12:41:47.230-0700 ** WARNING: --rest is specified without --httpinterface, 2015-07-01T12:41:47.230-0700 ** enabling http interface > db.version() 2.6.10 > version() 2.6.10 > > db.test.find( { $where: "this.credits == this.debits" } ) 2015-07-01T12:36:12.748-0700 DBClientCursor::init call() failed Error: error doing query: failed 2015-07-01T12:36:12.750-0700 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed 2015-07-01T12:36:12.751-0700 warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused ...

      Running example from docs
      (http://docs.mongodb.org/v2.6/reference/operator/query/where/):

      db.test.find( { $where: "this.credits == this.debits" } );
      

      produced instant segfault:

      2015-07-01T12:36:12.331-0700 [conn1] SEVERE: Invalid access at address: 0x20
      2015-07-01T12:36:12.654-0700 [conn1] SEVERE: Got signal: 11 (Segmentation fault).
      Backtrace:0x121eb61 0x121df3e 0x121e02f 0x7f038822a0d0 0x1504115 0x15d2e1f 0x150513e 0x1505159 0x15a0b8e 0x14e5b22 0x15a0cc0 0x1316e37 0x15a76da 0x117a005 0x118d539 0x116dd93 0xc10484 0xc10c0f 0xc086fc 0xc03226 
       /usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0x121eb61]
       /usr/bin/mongod() [0x121df3e]
       /usr/bin/mongod() [0x121e02f]
       /lib64/libpthread.so.0(+0x100d0) [0x7f038822a0d0]
       /usr/bin/mongod(_ZN2v88internal2OS8AllocateEmPmb+0xe5) [0x1504115]
       /usr/bin/mongod(_ZN2v88internal28CreateTranscendentalFunctionENS0_19TranscendentalCache4TypeE+0x3f) [0x15d2e1f]
       /usr/bin/mongod(_ZN2v88internal22init_fast_sin_functionEv+0xe) [0x150513e]
       /usr/bin/mongod(_ZN2v88internal14POSIXPostSetUpEv+0x9) [0x1505159]
       /usr/bin/mongod(_ZN2v88internal2V828InitializeOncePerProcessImplEv+0x3e) [0x15a0b8e]
       /usr/bin/mongod(_ZN2v88internal12CallOnceImplEPlPFvPvES2_+0x62) [0x14e5b22]
       /usr/bin/mongod(_ZN2v88internal2V810InitializeEPNS0_12DeserializerE+0x20) [0x15a0cc0]
       /usr/bin/mongod(_ZN2v82V810InitializeEv+0x47) [0x1316e37]
       /usr/bin/mongod(_ZN2v86LockerC1EPNS_7IsolateE+0x9a) [0x15a76da]
       /usr/bin/mongod(_ZN5mongo7V8ScopeC1EPNS_14V8ScriptEngineE+0x3c5) [0x117a005]
       /usr/bin/mongod(_ZN5mongo14V8ScriptEngine11createScopeEv+0x29) [0x118d539]
       /usr/bin/mongod(_ZN5mongo12ScriptEngine14getPooledScopeERKSsS2_+0x283) [0x116dd93]
       /usr/bin/mongod(_ZN5mongo20WhereMatchExpression4initERKNS_10StringDataES3_RKNS_7BSONObjE+0x2e4) [0xc10484]
       /usr/bin/mongod(_ZN5mongo33expressionParserWhereCallbackRealERKNS_11BSONElementE+0x22f) [0xc10c0f]
       /usr/bin/mongod(_ZN5boost6detail8function17function_invoker1IPFN5mongo10StatusWithIPNS3_15MatchExpressionEEERKNS3_11BSONElementEES7_SA_E6invokeERNS1_15function_bufferESA_+0xc) [0xc086fc]
       /usr/bin/mongod(_ZN5mongo21MatchExpressionParser6_parseERKNS_7BSONObjEi+0xf16) [0xc03226]
      

      Server configs are defaults except:
      added http interface
      created replicaset with one member to get oplogs:

      grep '^[^#]' /etc/mongod.conf
      rest=true
      nohttpinterface=false
      logpath=/var/log/mongodb/mongod.log
      logappend=true
      fork=true
      dbpath=/var/lib/mongo
      pidfilepath=/var/run/mongodb/mongod.pid
      bind_ip=127.0.0.1
      replSet=localhost
      

            Assignee:
            sam.kleinman Sam Kleinman (Inactive)
            Reporter:
            ccjon Jon Gorrono
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: