I have a really simple method that initializes v8, I am unable to track the reason (other v8 stuff works just fine):
void JavascriptEngine::init() {
m_platform = v8::platform::NewDefaultPlatform();
v8::V8::InitializeExternalStartupData(".");
v8::V8::InitializeICU();
v8::V8::InitializePlatform(&*m_platform);
v8::V8::Initialize();
v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator =
v8::ArrayBuffer::Allocator::NewDefaultAllocator();
m_isolate = v8::Isolate::New(create_params);
v8::Isolate::Scope isolate_scope(m_isolate);
v8::HandleScope handle_scope(m_isolate);
m_context = make_unique<v8::Persistent<v8::Context>>(m_isolate,
create_new_context());
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(m_isolate);
t->SetClassName(v8::String::NewFromUtf8(m_isolate, "Test", v8::NewStringType::kNormal).ToLocalChecked());
t->Set(m_isolate, "func_property", v8::Number::New(m_isolate, 1));
auto f = t->GetFunction(); // CRASH
...//rest of the code
}
Error I got:
Exception thrown: read access violation.
**this** was nullptr.
Using Visual Studio 2017. What am I missing?