Thanks for the asan tip Jochen, that's just the sort of thing I was looking
for but didn't know existed
I believe i've fixed it! Although I don't fully understand the cause. It
seems to be to related to Java Native Interface and v8 not playing well
together
Here's what worked, in case someone else has this issue:
I was using JNI's NewStringUTF function to allocate a java string to pass
into a java function call, once the call had been made I was using
ReleaseStringUTFChars, which would let the java GC free the memory. The fix
seemed to be forcing Java to trash the string before the function exits
using DeleteLocalRef.
Full corrected function:
void AndroidMediaPlayer::setDataSource(const
v8::FunctionCallbackInfo& p___args) {
v8::Locker locker(p___args.GetIsolate());
v8::HandleScope scope(p___args.GetIsolate());
node::commons* com = node::commons::getInstanceIso(p___args.GetIsolate());
v8::Isolate * __contextORisolate = p___args.GetIsolate();
jxcore::PArguments args(p___args);
if(com->expects_reset) RETURN();
v8::Local jsPath = args.GetAsString(0);
const char* cPath = STRING_TO_STD(jsPath);
jstring jPath = env->NewStringUTF(cPath);
env->CallVoidMethod(AndroidMediaPlayer::GetNative(args.Holder())->jniMediaPlayer,
setDataSourceId, jPath);
HANDLE_JNI_EXCEPTIONS(env);
//we _must_ deleteLocalRef rather than release, not deleting immediately
causes crash in v8
env->DeleteLocalRef(jPath);
}
(The crash would occur the same way with or without the v8::String code and
the java function call, the only thing required to trigger it was calling
NewStringUTF and ReleaseStringUTFChars)
On Friday, March 11, 2016 at 7:04:53 AM UTC, Jochen Eisinger wrote:
>
> It's really difficult to even begin guessing what could cause this:
> without the source, and more information about the crash like a call stack
> and values of local variables, there's not much I can do.
>
> In general, compiling the code with asan might provide additional insights
> as to what corrupts the memory.
>
> Best
> Jochen
>
> On Thu, Mar 10, 2016, 10:22 PM George Corney > wrote:
>
>> Hey,
>>
>> I'm hoping someone with more experience than me can shed some light on my
>> issue.
>>
>> v8 is being run on a separate thread to the main thread, all interactions
>> with v8 occur on this thread
>>
>> The problem is that when an action (playing/pausing a film in android's
>> MediaPlayer) occurs on the main thread, the app has a high chance of
>> crashing either straight away or after a short period (can be as high as
>> 600ms).
>>
>> The crash is always the same (with differing address(:
>>
>> signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x45524854
>> Although occasionally SEGV_ACCERR might be SEGV_MAPERR.
>>
>> Stack frame #00 pc 0061d3ec /[...]/lib/arm/libnative_webgl.so
>> (v8::internal::AstValueFactory::Internalize(v8::internal::Isolate*)+56)
>>
>> SEGV_ACCERR and SEGV_MAPERR surely imply that the v8 thread is accessing
>> data on another thread, but as far as my code is concerned, nothing
>> interesting is happening when the crash occurs and if there are any calls
>> to js land they're happening on the thread v8 was created with.
>>
>> The code for AstValueFactory::Internalize is
>> void AstValueFactory::Internalize(Isolate* isolate) {
>> if (isolate_) {
>> // Everything is already internalized.
>> return;
>> }
>> // Strings need to be internalized before values, because values refer
>> to
>> // strings.
>> for (int i = 0; i < strings_.length(); ++i) {
>> strings_[i]->Internalize(isolate);
>> }
>> for (int i = 0; i < values_.length(); ++i) {
>> values_[i]->Internalize(isolate);
>> }
>> isolate_ = isolate;
>> }
>>
>>
>> Do you have any thoughts about what could cause this? If the media player
>> action is corrupting memory in some way, is there some reason that it
>> always crashes on this particular function?
>>
>> I'm using v8 3.2.8 on Android (via NDK). (unfortunately upgrading to more
>> recent v8 isn't an option).
>>
>> v8::Locker is used before every handle_scope, should I be doing something
>> else to ensure thread safety?
>>
>> Been on this problem for a long time now, any insight someone might have
>> will be useful.
>>
>> Thanks,
>> George Corney
>>
>> --
>> --
>> 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.
>>
>
--
--
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 m