0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-01 20:25:12 -05:00

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.
This commit is contained in:
Bert Belder 2019-05-02 20:40:21 +02:00
parent ae0544b7ce
commit 48bcfce09e
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461

View file

@ -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);