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

$where clause can crash server

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.4.0
    • Component/s: None
    • Labels:
      None
    • Environment:
      OSX: 10.3.0 Darwin Kernel Version 10.3.0: Fri Feb 26 11:58:09 PST 2010; root:xnu-1504.3.12~1/RELEASE_I386 i386
      mongodb-osx-x86_64-1.4.0

      Run a $where clause and attempt to dereference a null value. The server will fail with "TypeError: this.x has no properties nofile_a:0" and assert. The server will no longer respond to queries:

      > db.foo.save(

      {a:1}

      )
      > db.foo.find({$where:"this.x.x"})
      error: {
      "$err" : "error on invocation of $where function:
      JS Error: TypeError: this.x has no properties nofile_a:0"

      From the server:

      Tue Mar 30 10:16:52 JS Error: TypeError: this.x has no properties nofile_a:0
      Tue Mar 30 10:16:52 User Exception 10071:error on invocation of $where function:
      JS Error: TypeError: this.x has no properties nofile_a:0
      Tue Mar 30 10:16:52 Assertion: 10362:error on invocation of $where function:
      JS Error: TypeError: this.x has no properties nofile_a:0
      0x100067c57 0x1000c74de 0x100162c84 0x100165a4d 0x10022330b 0x10022c6f4 0x7fff8346a8b6 0x7fff8346a769
      0 mongod 0x0000000100067c57 _ZN5mongo11msgassertedEiPKc + 487
      1 mongod 0x00000001000c74de _ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpE + 7534
      2 mongod 0x0000000100162c84 _ZN5mongo13receivedQueryERNS_6ClientERNS_10DbResponseERNS_7MessageE + 644
      3 mongod 0x0000000100165a4d _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERK11sockaddr_in + 3629
      4 mongod 0x000000010022330b _ZN5mongo10connThreadEv + 619
      5 mongod 0x000000010022c6f4 thread_proxy + 132
      6 libSystem.B.dylib 0x00007fff8346a8b6 _pthread_start + 331
      7 libSystem.B.dylib 0x00007fff8346a769 thread_start + 13
      Tue Mar 30 10:16:52 Caught Assertion in runQuery ns:dotspots.foo massert:error on invocation of $where function:
      JS Error: TypeError: this.x has no properties nofile_a:0
      Tue Mar 30 10:16:52 ntoskip:0 ntoreturn:0
      Tue Mar 30 10:16:52 query:

      { $where: "this.x.x" }

            Assignee:
            eliot Eliot Horowitz (Inactive)
            Reporter:
            mmastrac Matt Mastracci
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: