Commit 65a8d2de authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[d8] Fix termination while creating realm

A worker might be terminated while creating a new Realm. While this was
handled mostly correctly already, a DCHECK was places slightly too
early, which is fixed by this CL.
Also, we avoid printing an error message if we fail to install an
extension due to isolate termination. As this is externally triggered,
it's not really an error condition.

R=jkummerow@chromium.org

Bug: chromium:1313475
Change-Id: I67b7fd27002d9b9a33439378d8336fefb2a2371a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3571811Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79825}
parent 0dc4d88c
......@@ -1789,8 +1789,8 @@ MaybeLocal<Context> Shell::CreateRealm(
Local<ObjectTemplate> global_template = CreateGlobalTemplate(isolate);
Local<Context> context =
Context::New(isolate, nullptr, global_template, global_object);
DCHECK(!try_catch.HasCaught());
if (context.IsEmpty()) return MaybeLocal<Context>();
DCHECK(!try_catch.HasCaught());
InitializeModuleEmbedderData(context);
data->realms_[index].Reset(isolate, context);
data->realms_[index].AnnotateStrongRetainer(kGlobalHandleLabel);
......
......@@ -5982,14 +5982,14 @@ bool Genesis::InstallExtension(Isolate* isolate,
return false;
}
}
bool result = CompileExtension(isolate, extension);
if (!result) {
if (!CompileExtension(isolate, extension)) {
// If this failed, it either threw an exception, or the isolate is
// terminating.
DCHECK(isolate->has_pending_exception() ||
(isolate->has_scheduled_exception() &&
isolate->scheduled_exception() ==
ReadOnlyRoots(isolate).termination_exception()));
if (isolate->has_pending_exception()) {
// We print out the name of the extension that fail to install.
// When an error is thrown during bootstrapping we automatically print
// the line number at which this happened to the console in the isolate
......@@ -5998,8 +5998,13 @@ bool Genesis::InstallExtension(Isolate* isolate,
current->extension()->name());
isolate->clear_pending_exception();
}
return false;
}
DCHECK(!isolate->has_pending_exception() &&
!isolate->has_scheduled_exception());
extension_states->set_state(current, INSTALLED);
return result;
return true;
}
bool Genesis::ConfigureGlobalObject(
......
// Copyright 2022 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: --expose-gc --invoke-weak-callbacks --random-gc-interval=2000
// We spawn a new worker which creates a Realm, then terminate the main thread
// which will also terminate the worker.
new Worker(`Realm.create();`, {type: 'string'});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment