调用 Isolate::New() 后执行位置 0x0000000000000000 时发生访问冲突

Jam*_*ins 4 c++ v8 embedded-v8

我似乎无法弄清楚如何启动 V8。我有这个代码:

if (!_V8Initialized)
{
    v8::V8::InitializeICU();

    v8::V8::InitializeExternalStartupData("x86\\"); // (this loads ok, I checked)

    auto platform = v8::platform::CreateDefaultPlatform();
    v8::V8::InitializePlatform(platform);

    v8::V8::Initialize();

    _V8Initialized = true;
}

auto params = Isolate::CreateParams();
params.array_buffer_allocator = ArrayBuffer::Allocator::NewDefaultAllocator();
_Isolate = Isolate::New(params);
Run Code Online (Sandbox Code Playgroud)

但我收到这个错误:

V8.Net.Console.exe 中的 0x0000000000000000 处抛出异常:0xC0000005:执行位置 0x0000000000000000 时发生访问冲突。

v8_libbase.dll!v8::base::OS::Abort() 第 832 行 C++ v8_libbase.dll!V8_Fatal(const char * file, int line, const char * format, ...) 第 74 行 C++ v8.dll!v8 ::internal::SnapshotData::SnapshotData(const v8::internal::Vector snapshot) 第 28 行 C++ v8.dll!v8::internal::Snapshot::Initialize(v8::internal::Isolate *isolate) 第 43 行C++ v8.dll!v8::Isolate::New(const v8::Isolate::CreateParams & params) 第 8237 行 C++ V8_Net_Proxy_x64.dll!V8EngineProxy::V8EngineProxy(bool enableDebugging, void( )() debugMessageDispatcher, int debugPort) 行89 C++ V8_Net_Proxy_x64.dll!CreateV8EngineProxy(bool enableDebugging, void( )() debugMessageDispatcher, int debugPort) 第 19 行 C++ [托管到本机转换]
V8.Net.dll!V8.Net.V8Engine.V8Engine() 第 246 行 C# V8。 Net.Console.exe!V8.Net.Program.Main(string[] args) 第 31 行 C# [本机到托管转换]
mscoreei.dll!00007ffdbdd281ad() 未知 mscoree.dll!00007ffdbddc10ab() 未知 kernel32.dll!00007ffdd3868364( ) 未知 ntdll.dll!00007ffdd5ef70d1() 未知

这里似乎失败了:

explicit SnapshotData(const Vector<const byte> snapshot)
  : SerializedData(const_cast<byte*>(snapshot.begin()), snapshot.length()) {
    CHECK(IsSane()); <-- THIS FAILS
}
Run Code Online (Sandbox Code Playgroud)

我在这里遵循了源代码(大部分):https://chromium.googlesource.com/v8/v8/+/branch-heads/4.8/samples/hello-world.cc

...但我不确定为什么我似乎收到了空错误。我肯定错过了什么...

Jam*_*ins 5

没关系,我似乎总是在发布到 SO 后就能解决问题,哈哈。事实证明,我是从 x86 目录加载的,而不是 x64 目录(鉴于 V8_Net_Proxy_x64.dll,我应该猜到!哈哈)。

我本来打算删除这个问题,但无论如何我都会把这个问题留在这里,以防其他人在半夜半睡半醒时陷入这个问题。;)