Commit 521c2ff7 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[inspector][fuzzer] Handle termination while creating context

This happens flakily on ClusterFuzz. It might not be relevant for users,
but fixing it will allow ClusterFuzz to make more progress.

R=szuend@chromium.org

Bug: chromium:1190898
Change-Id: I7d0b705ff66e80e17ffc322b5d5fd5eb252d5965
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2778174Reviewed-by: 's avatarSimon Zünd <szuend@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73596}
parent 3eefe536
......@@ -322,8 +322,9 @@ class UtilsExtension : public IsolateData::SetupGlobalTask {
ToVector(args.GetIsolate(), args[1].As<v8::String>());
RunSyncTask(backend_runner_, [&context_group_id, name](IsolateData* data) {
data->CreateContext(context_group_id,
v8_inspector::StringView(name.data(), name.size()));
CHECK(data->CreateContext(
context_group_id,
v8_inspector::StringView(name.data(), name.size())));
});
}
......
......@@ -72,11 +72,14 @@ IsolateData* IsolateData::FromContext(v8::Local<v8::Context> context) {
int IsolateData::CreateContextGroup() {
int context_group_id = ++last_context_group_id_;
CreateContext(context_group_id, v8_inspector::StringView());
if (!CreateContext(context_group_id, v8_inspector::StringView())) {
DCHECK(isolate_->IsExecutionTerminating());
return -1;
}
return context_group_id;
}
void IsolateData::CreateContext(int context_group_id,
bool IsolateData::CreateContext(int context_group_id,
v8_inspector::StringView name) {
v8::HandleScope handle_scope(isolate_.get());
v8::Local<v8::ObjectTemplate> global_template =
......@@ -87,12 +90,14 @@ void IsolateData::CreateContext(int context_group_id,
}
v8::Local<v8::Context> context =
v8::Context::New(isolate_.get(), nullptr, global_template);
if (context.IsEmpty()) return false;
context->SetAlignedPointerInEmbedderData(kIsolateDataIndex, this);
// Should be 2-byte aligned.
context->SetAlignedPointerInEmbedderData(
kContextGroupIdIndex, reinterpret_cast<void*>(context_group_id * 2));
contexts_[context_group_id].emplace_back(isolate_.get(), context);
if (inspector_) FireContextCreated(context, context_group_id, name);
return true;
}
v8::Local<v8::Context> IsolateData::GetDefaultContext(int context_group_id) {
......
......@@ -50,7 +50,8 @@ class IsolateData : public v8_inspector::V8InspectorClient {
// Setting things up.
int CreateContextGroup();
void CreateContext(int context_group_id, v8_inspector::StringView name);
V8_NODISCARD bool CreateContext(int context_group_id,
v8_inspector::StringView name);
void ResetContextGroup(int context_group_id);
v8::Local<v8::Context> GetDefaultContext(int context_group_id);
int GetContextGroupId(v8::Local<v8::Context> context);
......
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