[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/+/3571811 Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#79825}
This commit is contained in:
parent
0dc4d88c60
commit
65a8d2dea1
@ -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,24 +5982,29 @@ 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()));
|
||||
// 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
|
||||
// error throwing functionality.
|
||||
base::OS::PrintError("Error installing extension '%s'.\n",
|
||||
current->extension()->name());
|
||||
isolate->clear_pending_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
|
||||
// error throwing functionality.
|
||||
base::OS::PrintError("Error installing extension '%s'.\n",
|
||||
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(
|
||||
|
9
test/mjsunit/regress/regress-1313475.js
Normal file
9
test/mjsunit/regress/regress-1313475.js
Normal file
@ -0,0 +1,9 @@
|
||||
// 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'});
|
Loading…
Reference in New Issue
Block a user