if (extensions == NULL) extensions = &no_extensions;
i::Handle<i::Context> env =
CreateEnvironment(isolate, extensions, global_template, global_object);
- if (env.is_null()) return Local<Context>();
+ if (env.is_null()) {
+ if (isolate->has_pending_exception()) {
+ isolate->OptionalRescheduleException(true);
+ }
+ return Local<Context>();
+ }
return Utils::ToLocal(scope.CloseAndEscape(env));
}
// Realm.create() creates a new realm and returns its index.
void Shell::RealmCreate(const v8::FunctionCallbackInfo<v8::Value>& args) {
Isolate* isolate = args.GetIsolate();
+ TryCatch try_catch(isolate);
PerIsolateData* data = PerIsolateData::Get(isolate);
Persistent<Context>* old_realms = data->realms_;
int index = data->realm_count_;
}
delete[] old_realms;
Handle<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
- data->realms_[index].Reset(
- isolate, Context::New(isolate, NULL, global_template));
+ Local<Context> context = Context::New(isolate, NULL, global_template);
+ if (context.IsEmpty()) {
+ DCHECK(try_catch.HasCaught());
+ try_catch.ReThrow();
+ return;
+ }
+ data->realms_[index].Reset(isolate, context);
args.GetReturnValue().Set(index);
}
--- /dev/null
+// Copyright 2015 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.
+
+// Flags: --stack-size=100
+
+function f() {
+ try {
+ f();
+ } catch(e) {
+ Realm.create();
+ }
+}
+f();