diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index a48bb4df4d..298652e0f9 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -1301,6 +1301,12 @@ bool Genesis::CompileNative(Vector name, Handle source) { #ifdef ENABLE_DEBUGGER_SUPPORT isolate->debugger()->set_compiling_natives(true); #endif + // During genesis, the boilerplate for stack overflow won't work until the + // environment has been at least partially initialized. Add a stack check + // before entering JS code to catch overflow early. + StackLimitCheck check(Isolate::Current()); + if (check.HasOverflowed()) return false; + bool result = CompileScriptCached(name, source, NULL, diff --git a/src/debug.cc b/src/debug.cc index 457531fa36..99256ba21a 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -820,6 +820,9 @@ bool Debug::Load() { v8::Handle(), NULL); + // Fail if no context could be created. + if (context.is_null()) return false; + // Use the debugger context. SaveContext save(isolate_); isolate_->set_context(*context);