Skip to content

Commit

Permalink
SERVER-8021: on v8 OOM, throw instead of abort
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Becker committed Dec 24, 2012
1 parent 168d8b6 commit a7169fd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/mongo/scripting/engine_v8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,10 @@ namespace mongo {
// required for busy loops in javascript which do not call native functions.
v8::Locker::StartPreemption(500);

// if the isolate runs out of heap space, raise a flag on the StackGuard instead of
// calling abort()
v8::V8::IgnoreOutOfMemoryException();

// create a global (rooted) object
_global = Persistent< v8::Object >::New( _context->Global() );

Expand Down Expand Up @@ -861,7 +865,11 @@ namespace mongo {
}

if (result.IsEmpty()) {
_error = mongoutils::str::stream() << "javascript execution failed: " << toSTLString(&try_catch);
_error = mongoutils::str::stream() << "javascript execution failed: ";
if (try_catch.HasCaught())
_error += toSTLString(&try_catch);
if (hasOutOfMemoryException())
_error += "v8 out of memory";
log() << _error << endl;
return 1;
}
Expand Down

0 comments on commit a7169fd

Please sign in to comment.