Embedded v8 in Android: crash when executing persistent Function in another thread

46 views
Skip to first unread message

Kevin Read

unread,
Nov 10, 2016, 6:14:09 AM11/10/16
to v8-users
Hi all,

I'm in the process of porting my embedded v8 from a very old version to current stable. I have this code that is called from JNI from a different thread than the one that initially created the Isolate and the initial context:

v8::Locker l (isolate);
Isolate::Scope isolateScope(isolate);
Context::Scope context_scope(*reinterpret_cast<Local<Context>*>(context->_context));

HandleScope scope (isolate);
TryCatch trycatch;

// Get pointers to persistent objects created by 'new Persistent<T>(_local)'
WrapPersistentObj* wo = (WrapPersistentObj*)thisPtr;
Local<Object> thisObj = (*reinterpret_cast<Local<Object>*>(&wo->obj));
WrapPersistentFunc* ws = (WrapPersistentFunc*)jsCbPtr;
Local<Function> callbackP = Local<Function>::New(isolate, *reinterpret_cast<Local<Function>*>(&ws->callbackFunc));
int argcount = 0;
Handle<Value> argarray[] = { };

Handle<Value> result = callbackP->Call(thisObj, argcount, argarray);

The Call method crashes with this message in debug build (doesn't crash in release build):

11-10 12:08:25.665  32122    32162                     v8  #

11-10 12:08:25.665  32122    32162                     v8  # Fatal error in ../../src/parsing/parser.cc, line 730

11-10 12:08:25.665  32122    32162                     v8  #

11-10 12:08:25.665  32122    32162                     v8  Check failed: ThreadId::Current().Equals(info->isolate()->thread_id()).

11-10 12:08:25.665  32122    32162                     v8  #

11-10 12:08:25.667  32122    32162                   libc  Fatal signal 4 (SIGILL), code 1, fault addr 0x997d2f98 in tid 32162 (V8Engine)

11-10 12:08:25.670   271      271                          debuggerd: handling request: pid=32122 uid=10116 gid=10116 tid=32162

11-10 12:08:25.704  32212    32212                  DEBUG  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***


All access to the Isolate in all parts of the app is protected by Locker instances, so I'm not sure where this comes from.


Any help would be appreciated.


Thanks and best,

Kevin

Jochen Eisinger

unread,
Nov 10, 2016, 8:46:37 AM11/10/16
to v8-users
can you file a bug at crbug.com/v8/new please? It would be great if you could provide a complete repro case!

thanks
-jochen

--
--
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.
For more options, visit https://groups.google.com/d/optout.

Kevin Read

unread,
Nov 16, 2016, 10:13:58 AM11/16/16
to v8-users
Hi Jochen,

I've filed a bug (https://bugs.chromium.org/p/v8/issues/detail?id=5645). Since our SDK is open source I added pointers to code that will reproduce the issue.

Thanks and best,
Kevin
Reply all
Reply to author
Forward
0 new messages