Make GetDebugContext a bit more robust.
authorsvenpanne <svenpanne@chromium.org>
Wed, 8 Apr 2015 09:10:10 +0000 (02:10 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 8 Apr 2015 09:10:14 +0000 (09:10 +0000)
Perhaps we should throw an exception and/or change our external API to
use a MaybeLocal, but that would be a bigger change. For now, we just
return undefined when something goes wrong with the DebugContext,
which is good enough to avoid crashing.

BUG=chromium:474538
LOG=y

Review URL: https://codereview.chromium.org/1065213002

Cr-Commit-Position: refs/heads/master@{#27650}

src/debug.cc
src/runtime/runtime-debug.cc

index 66b0e0a..56756c4 100644 (file)
@@ -2804,6 +2804,7 @@ void Debug::ProcessCompileEventInDebugScope(v8::DebugEvent event,
 
 Handle<Context> Debug::GetDebugContext() {
   DebugScope debug_scope(this);
+  if (debug_scope.failed()) return Handle<Context>();
   // The global handle may be destroyed soon after.  Return it reboxed.
   return handle(*debug_context(), isolate_);
 }
index b4e1fe9..a3db178 100644 (file)
@@ -2659,6 +2659,7 @@ RUNTIME_FUNCTION(Runtime_GetDebugContext) {
   HandleScope scope(isolate);
   DCHECK(args.length() == 0);
   Handle<Context> context = isolate->debug()->GetDebugContext();
+  if (context.is_null()) return isolate->heap()->undefined_value();
   context->set_security_token(isolate->native_context()->security_token());
   return context->global_proxy();
 }