I don't see where you create the context? It looks like the persistent handle is never initialized.
On Sat, Mar 19, 2016, 10:02 AM Ben Noordhuis <i...@bnoordhuis.nl> wrote: > On Fri, Mar 18, 2016 at 10:55 AM, Daniel Burchardt > <danielburcha...@gmail.com> wrote: > > You are right. My new code: > > > > class Browser > > { > > public: > > Browser(); > > void getContext(); > > const char* execute(const char* data); > > int test; > > private: > > v8::Isolate* _isolate; > > v8::Persistent<v8::Context> _context; > > }; > > > > > > Browser::Browser() > > { > > v8::V8::InitializeICU(); > > v8::V8::InitializeExternalStartupData("/opt/v8build/"); > > v8::Platform* platform = v8::platform::CreateDefaultPlatform(); > > v8::V8::InitializePlatform(platform); > > v8::V8::Initialize(); > > > > ArrayBufferAllocator allocator; > > v8::Isolate::CreateParams create_params; > > create_params.array_buffer_allocator = &allocator; > > > > _isolate = v8::Isolate::New(create_params); > > } > > > > const char* Browser::execute(const char* data) > > { > > v8::Isolate::Scope isolate_scope(_isolate); > > v8::HandleScope handle_scope(_isolate); > > > > const char* result; > > { > > v8::Local<v8::Context> context = > > v8::Local<v8::Context>::New(_isolate, _context); > > > > v8::Context::Scope context_scope(context); > > > > v8::Local<v8::String> source = > > v8::String::NewFromUtf8(_isolate, data, > > v8::NewStringType::kNormal).ToLocalChecked(); > > > > v8::Local<v8::Script> script = v8::Script::Compile(context, > > source).ToLocalChecked(); > > v8::Local<v8::Value> result = script->Run(context).ToLocalChecked(); > > v8::String::Utf8Value utf8(result); > > > > // Konwersja danych do char* > > int len = utf8.length() + 1; > > char *str = (char *) calloc(sizeof(char), len); > > strncpy(str, *utf8, len); > > > > return str; > > } > > > > return result; > > } > > > > > > Result is error > > > > Program received signal SIGSEGV, Segmentation fault. > > 0x00007ffff5998d9e in v8::Context::Enter() () from /opt/v8build/hello.so > > Try it with a debug build (`make -j8 x64.debug extrachecks=on`), that > should hopefully give you an error message rather than a segmentation > fault. > > -- > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.