Commit 1d1dd8ee authored by Ben Smith's avatar Ben Smith Committed by Commit Bot

[d8] Fix locking bug w/ externalized contents

|Shell::externalized_contents_| is guarded by |Shell::workers_mutex_|,
but wasn't being acquired when the serialize WriteValue call failed.

Bug: v8:8034
Change-Id: Idd0448e9f44d6b26c17987405d5d7394449e8bb3
Reviewed-on: https://chromium-review.googlesource.com/1170316Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Ben Smith <binji@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55060}
parent b2537f21
......@@ -3278,15 +3278,14 @@ std::unique_ptr<SerializationData> Shell::SerializeValue(
bool ok;
Local<Context> context = isolate->GetCurrentContext();
Serializer serializer(isolate);
std::unique_ptr<SerializationData> data;
if (serializer.WriteValue(context, value, transfer).To(&ok)) {
std::unique_ptr<SerializationData> data = serializer.Release();
base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer());
serializer.AppendExternalizedContentsTo(&externalized_contents_);
return data;
data = serializer.Release();
}
// Append externalized contents even when WriteValue fails.
base::LockGuard<base::Mutex> lock_guard(workers_mutex_.Pointer());
serializer.AppendExternalizedContentsTo(&externalized_contents_);
return nullptr;
return data;
}
MaybeLocal<Value> Shell::DeserializeValue(
......
......@@ -543,7 +543,7 @@ class Shell : public i::AllStatic {
static base::LazyMutex context_mutex_;
static const base::TimeTicks kInitialTicks;
static base::LazyMutex workers_mutex_;
static base::LazyMutex workers_mutex_; // Guards the following members.
static bool allow_new_workers_;
static std::vector<Worker*> workers_;
static std::vector<ExternalizedContents> externalized_contents_;
......
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