Calling function from shared library in V8 7.7.299.11

39 views
Skip to first unread message

Darin Dimitrov

unread,
Sep 12, 2019, 8:54:18 AM9/12/19
to v8-users
I am cross compiling V8 for android and I have created a shared library containing a simple function which adds some property to a provided object:

extern "C" void MyFunc(Isolate* isolate, Local<Object>& obj) {
Local<Context> context = isolate->GetCurrentContext();
obj->Set(context, v8::String::NewFromUtf8(isolate, "someProp").ToLocalChecked(), Number::New(isolate, 500));
}

My goal  purpose is to call this function from my android application in which I have embedded V8:

typedef void (*MyCallback)(Isolate* isolate, Local<Object>& obj);

void* handle = dlopen("/data/data/com.tns.testapplication/files/app/modules/libCalc-x86_64.so", RTLD_LAZY);
MyCallback func = reinterpret_cast<MyCallback>(dlsym(handle, "MyFunc"));
Local<Object> exportsObj = Object::New(isolate);
func(isolate, exportsObj);

This successfully invokes "MyFunc" from the shared library and sets the "someProp" property on the passed object. 

Starting from V8 7.7.299.11 calling obj->Set() inside the library crashes with SIGSEGV and without any stacktrace.

I have noticed that if I set the property before calling the function then it works:

exportsObj->Set(context, v8::String::NewFromUtf8(isolate, "someProp").ToLocalChecked(), v8::Null(isolate));
func(isolate, exportsObj);

Any idea what might have changed between the official V8 7.6 and 7.7 releases that might explain this behaviour or any tips that would allow me to debug this further?

Jakob Gruber

unread,
Sep 12, 2019, 9:16:00 AM9/12/19
to v8-u...@googlegroups.com
Could this be another libcxx mismatch issue and 7.7 just exposes it incidentally?

--
--
v8-users mailing list
v8-u...@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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/48a71b41-b96e-41ec-9450-fa36d6f1bb45%40googlegroups.com.

Darin Dimitrov

unread,
Sep 12, 2019, 9:26:50 AM9/12/19
to v8-users
It might be, but normally I build my .so with the exact same custom libc++ which I use to build my android app. I am also able to perform other operations on the object such as ->Get


On Thursday, September 12, 2019 at 4:16:00 PM UTC+3, Jakob Gruber wrote:
Could this be another libcxx mismatch issue and 7.7 just exposes it incidentally?

On Thu, Sep 12, 2019 at 2:54 PM Darin Dimitrov <darin....@gmail.com> wrote:
I am cross compiling V8 for android and I have created a shared library containing a simple function which adds some property to a provided object:

extern "C" void MyFunc(Isolate* isolate, Local<Object>& obj) {
Local<Context> context = isolate->GetCurrentContext();
obj->Set(context, v8::String::NewFromUtf8(isolate, "someProp").ToLocalChecked(), Number::New(isolate, 500));
}

My goal  purpose is to call this function from my android application in which I have embedded V8:

typedef void (*MyCallback)(Isolate* isolate, Local<Object>& obj);

void* handle = dlopen("/data/data/com.tns.testapplication/files/app/modules/libCalc-x86_64.so", RTLD_LAZY);
MyCallback func = reinterpret_cast<MyCallback>(dlsym(handle, "MyFunc"));
Local<Object> exportsObj = Object::New(isolate);
func(isolate, exportsObj);

This successfully invokes "MyFunc" from the shared library and sets the "someProp" property on the passed object. 

Starting from V8 7.7.299.11 calling obj->Set() inside the library crashes with SIGSEGV and without any stacktrace.

I have noticed that if I set the property before calling the function then it works:

exportsObj->Set(context, v8::String::NewFromUtf8(isolate, "someProp").ToLocalChecked(), v8::Null(isolate));
func(isolate, exportsObj);

Any idea what might have changed between the official V8 7.6 and 7.7 releases that might explain this behaviour or any tips that would allow me to debug this further?

--
--
v8-users mailing list
v8-u...@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-u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages