2

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.

Ludek Vodicka
  • 1,610
  • 1
  • 18
  • 33

1 Answers1

2

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.

jmrk
  • 34,271
  • 7
  • 59
  • 74
  • Thanks a lot for reply. I already tried also to create snapshot_blob.bin in the path, but in case that this file is empty, there is another error: "Debug check failed: snapshot_blob->raw_size > 0 (0 vs. 0)." So maybe this file has to be pre-created somehow, but I didn't find any mention about this in the doc (and also any example didn't say anything about pre-creating the file). Regarding V8_USE_EXTERNAL_STARTUP_DATA, it's compiled with this flag. – Ludek Vodicka Oct 25 '21 at 11:49
  • Your last sentence just began to make sense for me. This bin file isn't created by V8 in runtime, but it's pre-compiled during build. I have this file in the build, so I can continue with the testing. – Ludek Vodicka Oct 25 '21 at 11:52
  • Thanks a lot, it's working! – Ludek Vodicka Oct 25 '21 at 11:53