summaryrefslogtreecommitdiff
path: root/core/libdeno/api.cc
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2019-05-02 20:40:21 +0200
committerBert Belder <bertbelder@gmail.com>2019-05-02 20:46:56 +0200
commit48bcfce09e11901244447617be2eb7789427eab0 (patch)
tree692f8dd01db34dad067138cfb3d4803538865de8 /core/libdeno/api.cc
parentae0544b7ce8370fcd9322dd10a8c2ebdcbabe75c (diff)
Work around Windows-only V8 concurrent initialization crash
This patch provides a work-around for an apparent V8 bug where initializing multiple isolates concurrently leads to a crash on Windows. At the time of writing the cause of this crash is not exactly understood, but it seems to be related to the V8 internal function win64_unwindinfo::RegisterNonABICompliantCodeRange(), which didn't exist in older versions of V8.
Diffstat (limited to 'core/libdeno/api.cc')
-rw-r--r--core/libdeno/api.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/core/libdeno/api.cc b/core/libdeno/api.cc
index 1110b1d34..81add1d07 100644
--- a/core/libdeno/api.cc
+++ b/core/libdeno/api.cc
@@ -5,6 +5,10 @@
#include <iostream>
#include <string>
+// Cpplint bans the use of <mutex> because it duplicates functionality in
+// chromium //base. However Deno doensn't use that, so suppress this lint.
+#include <mutex> // NOLINT
+
#include "third_party/v8/include/libplatform/libplatform.h"
#include "third_party/v8/include/v8.h"
#include "third_party/v8/src/base/logging.h"
@@ -53,7 +57,20 @@ Deno* deno_new(deno_config config) {
params.snapshot_blob = &d->snapshot_;
}
- v8::Isolate* isolate = v8::Isolate::New(params);
+ v8::Isolate* isolate;
+ {
+#ifdef _WIN32
+ // Work around an apparent V8 bug where initializing multiple isolates
+ // concurrently leads to a crash. At the time of writing the cause of this
+ // crash is not exactly understood, but it seems to be related to the V8
+ // internal function win64_unwindinfo::RegisterNonABICompliantCodeRange(),
+ // which didn't exist in older versions of V8.
+ static std::mutex mutex;
+ std::lock_guard<std::mutex> lock(mutex);
+#endif
+ isolate = v8::Isolate::New(params);
+ }
+
d->AddIsolate(isolate);
v8::Locker locker(isolate);