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

Large arrays in v8 can crash process with out of memory assertion

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • ALL

      Note that these arrays are all bigger than 16MB

      Crashing mongo

      $ mongo
      MongoDB shell version: 2.4.0-rc2-pre-
      connecting to: test
      Server has startup warnings: 
      Tue Mar  5 11:11:13.718 [initandlisten] 
      Tue Mar  5 11:11:13.718 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
      > var i = 0
      > var arr = []
      > for (i = 0; i<2000000; i++) { arr.push(Math.random());  }
      2000000
      > db.foo.insert({a:arr})
      
      #
      # Fatal error in CALL_AND_RETRY_2
      # Allocation failed - process out of memory
      #
      
      Tue Mar  5 11:36:27.935 mongo got signal 6 (Abort trap: 6), stack trace: 
      
      Tue Mar  5 11:36:27.937 0x10a45008b 0x10a36529f 0x7fff8e5af8ea 0 0x7fff8e606dce 0x10a678bbb 0x10a512046 0x10a4cfd3b 0x10a4ece92 0x10a552aca 0x10a4dd9cd 0x10a4107dc 0x10a410b60 0x10a410881 0x10a42891a 0x10a41235d 0x10a50fc60 0x352a5706362 0x352a574e13a 0x352a570c76e 
       0   mongo                               0x000000010a45008b _ZN5mongo15printStackTraceERSo + 43
       1   mongo                               0x000000010a36529f _Z12quitAbruptlyi + 191
       2   libsystem_c.dylib                   0x00007fff8e5af8ea _sigtramp + 26
       3   ???                                 0x0000000000000000 0x0 + 0
       4   libsystem_c.dylib                   0x00007fff8e606dce abort + 143
       5   mongo                               0x000000010a678bbb _ZN2v88internal2OS5AbortEv + 9
       6   mongo                               0x000000010a512046 _Z9API_FatalPKcS0_z + 166
       7   mongo                               0x000000010a4cfd3b _ZN2v8L24DefaultFatalErrorHandlerEPKcS1_ + 107
       8   mongo                               0x000000010a4ece92 _ZN2v88internal2V823FatalProcessOutOfMemoryEPKcb + 518
       9   mongo                               0x000000010a552aca _ZN2v88internal7Factory14CopyFixedArrayENS0_6HandleINS0_10FixedArrayEEE + 594
       10  mongo                               0x000000010a4dd9cd _ZN2v86Object16GetPropertyNamesEv + 295
       11  mongo                               0x000000010a4107dc _ZN5mongo7V8Scope9v8ToMongoEN2v86HandleINS1_6ObjectEEEi + 722
       12  mongo                               0x000000010a410b60 _ZN5mongo7V8Scope16v8ToMongoElementERNS_14BSONObjBuilderERKSsN2v86HandleINS5_5ValueEEEiPNS_7BSONObjE + 444
       13  mongo                               0x000000010a410881 _ZN5mongo7V8Scope9v8ToMongoEN2v86HandleINS1_6ObjectEEEi + 887
       14  mongo                               0x000000010a42891a _ZN5mongo11mongoInsertEPNS_7V8ScopeERKN2v89ArgumentsE + 1242
       15  mongo                               0x000000010a41235d _ZN5mongo7V8Scope10v8CallbackERKN2v89ArgumentsE + 123
       16  mongo                               0x000000010a50fc60 _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 464
       17  ???                                 0x00000352a5706362 0x0 + 3653497807714
       18  ???                                 0x00000352a574e13a 0x0 + 3653498102074
       19  ???                                 0x00000352a570c76e 0x0 + 3653497833326
      

      Crashing mongod

      $ mongo
      MongoDB shell version: 2.4.0-rc2-pre-
      connecting to: test
      Server has startup warnings: 
      Tue Mar  5 11:11:13.718 [initandlisten] 
      Tue Mar  5 11:11:13.718 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
      > function f () {
      ... var i = 0
      ... var arr = []
      ... for (i = 0; i<2000000; i++) { arr.push(Math.random());  }
      ... db.foo.insert({a:arr})
      ... }
      > db.eval(f);
      Tue Mar  5 11:38:15.810 DBClientCursor::init call() failed
      Tue Mar  5 11:38:15.811 JavaScript execution failed: Error: error doing query: failed at src/mongo/shell/query.js:L78
      Tue Mar  5 11:38:15.812 trying reconnect to 127.0.0.1:27017
      Tue Mar  5 11:38:15.812 reconnect 127.0.0.1:27017 failed couldn't connect to server 127.0.0.1:27017
      > exit
      bye
      

      mongod log

      #
      # Fatal error in CALL_AND_RETRY_2
      # Allocation failed - process out of memory
      #
      
      Tue Mar  5 11:38:15.779 Got signal: 6 (Abort trap: 6).
      
      Tue Mar  5 11:38:15.797 Backtrace:
      0x1059943eb 0x10555a3d1 0x7fff8e5af8ea 0 0x7fff8e606dce 0x105c18dbb 0x105ab2246 0x105a6ff3b 0x105a8d092 0x105af2cca 0x105a7dbcd 0x10595352c 0x1059538b0 0x1059535d1 0x10596831a 0x1059550ad 0x105aafe60 0x31e5cad06362 0x31e5cad383ba 0x31e5cad0c76e 
       0   mongod                              0x00000001059943eb _ZN5mongo15printStackTraceERSo + 43
       1   mongod                              0x000000010555a3d1 _ZN5mongo10abruptQuitEi + 225
       2   libsystem_c.dylib                   0x00007fff8e5af8ea _sigtramp + 26
       3   ???                                 0x0000000000000000 0x0 + 0
       4   libsystem_c.dylib                   0x00007fff8e606dce abort + 143
       5   mongod                              0x0000000105c18dbb _ZN2v88internal2OS5AbortEv + 9
       6   mongod                              0x0000000105ab2246 _Z9API_FatalPKcS0_z + 166
       7   mongod                              0x0000000105a6ff3b _ZN2v8L24DefaultFatalErrorHandlerEPKcS1_ + 107
       8   mongod                              0x0000000105a8d092 _ZN2v88internal2V823FatalProcessOutOfMemoryEPKcb + 518
       9   mongod                              0x0000000105af2cca _ZN2v88internal7Factory14CopyFixedArrayENS0_6HandleINS0_10FixedArrayEEE + 594
       10  mongod                              0x0000000105a7dbcd _ZN2v86Object16GetPropertyNamesEv + 295
       11  mongod                              0x000000010595352c _ZN5mongo7V8Scope9v8ToMongoEN2v86HandleINS1_6ObjectEEEi + 722
       12  mongod                              0x00000001059538b0 _ZN5mongo7V8Scope16v8ToMongoElementERNS_14BSONObjBuilderERKSsN2v86HandleINS5_5ValueEEEiPNS_7BSONObjE + 444
       13  mongod                              0x00000001059535d1 _ZN5mongo7V8Scope9v8ToMongoEN2v86HandleINS1_6ObjectEEEi + 887
       14  mongod                              0x000000010596831a _ZN5mongo11mongoInsertEPNS_7V8ScopeERKN2v89ArgumentsE + 1242
       15  mongod                              0x00000001059550ad _ZN5mongo7V8Scope10v8CallbackERKN2v89ArgumentsE + 123
       16  mongod                              0x0000000105aafe60 _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 464
       17  ???                                 0x000031e5cad06362 0x0 + 54863019926370
       18  ???                                 0x000031e5cad383ba 0x0 + 54863020131258
       19  ???                                 0x000031e5cad0c76e 0x0 + 54863019951982
      

      Another test case that fails and may be related

      $ mongo
      MongoDB shell version: 2.4.0-rc2-pre-
      connecting to: test
      Tue Mar  5 11:48:33.438 [initandlisten] connection accepted from 127.0.0.1:50050 #3 (1 connection now open)
      Server has startup warnings: 
      Tue Mar  5 11:46:37.978 [initandlisten] 
      Tue Mar  5 11:46:37.979 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
      > var i = 0
      > var arr = []
      > for (i = 0; i<2000000; i++) { arr.push(Math.random());  }
      2000000
      > arr.nonexistent()
      Tue Mar  5 11:48:48.124 JavaScript execution failed: 
      > arr2 = []
      Tue Mar  5 11:48:54.117 JavaScript execution failed -- v8 is out of memory
      error2:JavaScript execution failed -- v8 is out of memory
      >
      

            Assignee:
            benjamin.becker Ben Becker
            Reporter:
            sverch Shaun Verch
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: