I'm trying to use V8 library compiled via vcpkg install v8
but receiving the following error:
Failed to deserialize the V8 snapshot blob. This can mean that the snapshot blob file is corrupted or missing.
I'm testing it on shipped hello-world.cc
example:
v8::V8::InitializeICUDefaultLocation(argv[0]);
v8::V8::InitializeExternalStartupData(argv[0]);
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
Isolate::CreateParams create_params;
create_params.array_buffer_allocator =
v8::ArrayBuffer::Allocator::NewDefaultAllocator();
Isolate* isolate = Isolate::New(create_params); // << here is the crash
Isolate::Scope isolate_scope(isolate);
This error is generated in Isolate* isolate = Isolate::New(create_params);
because inner variable i_isole doesn't have assigned any snapshot_blog:
if (!i::Snapshot::Initialize(i_isolate)) {
// If snapshot data was provided and we failed to deserialize it must
// have been corrupted.
if (i_isolate->snapshot_blob() != nullptr) {
FATAL(
"Failed to deserialize the V8 snapshot blob. This can mean that the "
"snapshot blob file is corrupted or missing.");
}
Unfortunately, I'm not able to find any reference to this error. Thanks for any advice.
Updated: I'm trying it on Visual Studio 2019, the same on 32-bit build and 64-bit build too.
Updated: Based on vcpkg.json file, the version is "9.0.257.17". I will try to update it to the latest version if this is not some already fixed bug.
For v8::V8::InitializeExternalStartupData(argv[0]);
to work, make sure you have the file snapshot_blob.bin
in the same directory as the executable you've compiled. Alternatively, make sure you're passing the correct path instead of argv[0]
.
I don't know anything about vcpkg install v8
; it could be that the library you get that way is compiled without V8_USE_EXTERNAL_STARTUP_DATA
, in which case you should turn off external startup data for your build as well. If you don't have a snapshot_blob.bin
file at all, that would be an indicator that this is the case.