diff --git a/src/d8/d8.cc b/src/d8/d8.cc index f874cb6614..1af1baf198 100644 --- a/src/d8/d8.cc +++ b/src/d8/d8.cc @@ -339,10 +339,9 @@ static MaybeLocal TryGetValue(v8::Isolate* isolate, Local context, Local object, const char* property) { - Local v8_str = - String::NewFromUtf8(isolate, property).FromMaybe(Local()); - if (v8_str.IsEmpty()) return Local(); - return object->Get(context, v8_str); + MaybeLocal v8_str = String::NewFromUtf8(isolate, property); + if (v8_str.IsEmpty()) return {}; + return object->Get(context, v8_str.ToLocalChecked()); } static Local GetValue(v8::Isolate* isolate, Local context, @@ -1688,8 +1687,10 @@ void Shell::WorkerNew(const v8::FunctionCallbackInfo& args) { if (args.Length() > 1 && args[1]->IsObject()) { Local object = args[1].As(); Local context = isolate->GetCurrentContext(); - Local value = GetValue(args.GetIsolate(), context, object, "type"); - if (value->IsString()) { + Local value; + if (TryGetValue(args.GetIsolate(), context, object, "type") + .ToLocal(&value) && + value->IsString()) { Local worker_type = value->ToString(context).ToLocalChecked(); String::Utf8Value str(isolate, worker_type); if (strcmp("string", *str) == 0) { diff --git a/test/mjsunit/regress/regress-1110001.js b/test/mjsunit/regress/regress-1110001.js new file mode 100644 index 0000000000..41285c1202 --- /dev/null +++ b/test/mjsunit/regress/regress-1110001.js @@ -0,0 +1,17 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +function foo() { + try { + foo(); + } catch { + print('Stack overflow'); + Worker('string', new Proxy([], {})); + } +} +try { + foo(); +} catch { + // expecting stack overflow, but we should not crash. +}