diff options
author | Anna Henningsen <anna@addaleax.net> | 2016-05-20 22:55:37 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2016-05-24 17:03:02 +0200 |
commit | 4bd410bbbe2863da0baa36b9373d6b1491773102 (patch) | |
tree | 9c4fa53267b3c6f7366d12d59f9beeffd65178b3 /src | |
parent | cc6a78ebb278539896a9c717fb10cacfb2a98068 (diff) | |
download | android-node-v8-4bd410bbbe2863da0baa36b9373d6b1491773102.tar.gz android-node-v8-4bd410bbbe2863da0baa36b9373d6b1491773102.tar.bz2 android-node-v8-4bd410bbbe2863da0baa36b9373d6b1491773102.zip |
vm: don't abort process when stack space runs out
Make less assumptions about what objects will be available when
vm context creation or error message printing fail because V8
runs out of JS stack space.
Ref: https://github.com/nodejs/node/issues/6899
PR-URL: https://github.com/nodejs/node/pull/6907
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src')
-rw-r--r-- | src/node.cc | 4 | ||||
-rw-r--r-- | src/node_contextify.cc | 14 |
2 files changed, 12 insertions, 6 deletions
diff --git a/src/node.cc b/src/node.cc index e71c6a9f0a..cda2bac096 100644 --- a/src/node.cc +++ b/src/node.cc @@ -1521,8 +1521,8 @@ void AppendExceptionLine(Environment* env, // sourceline to 78 characters, and we end up not providing very much // useful debugging info to the user if we remove 62 characters. - int start = message->GetStartColumn(env->context()).FromJust(); - int end = message->GetEndColumn(env->context()).FromJust(); + int start = message->GetStartColumn(env->context()).FromMaybe(0); + int end = message->GetEndColumn(env->context()).FromMaybe(0); char arrow[1024]; int max_off = sizeof(arrow) - 2; diff --git a/src/node_contextify.cc b/src/node_contextify.cc index db83660308..bef7168ada 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -205,7 +205,11 @@ class ContextifyContext { Local<Context> ctx = Context::New(env->isolate(), nullptr, object_template); - CHECK(!ctx.IsEmpty()); + if (ctx.IsEmpty()) { + env->ThrowError("Could not instantiate context"); + return Local<Context>(); + } + ctx->SetSecurityToken(env->context()->GetSecurityToken()); // We need to tie the lifetime of the sandbox object with the lifetime of @@ -632,9 +636,11 @@ class ContextifyScript : public BaseObject { env->arrow_message_private_symbol()); Local<Value> arrow; - if (!(maybe_value.ToLocal(&arrow) && - arrow->IsString() && - stack->IsString())) { + if (!(maybe_value.ToLocal(&arrow) && arrow->IsString())) { + return; + } + + if (stack.IsEmpty() || !stack->IsString()) { return; } |