Java.lang.StackOverflow Error for Android L Preview

Jumping right into that theme, Android L introduces ART as the default runtime. I have an example app, basically a document viewer. Most of the document viewing code, including Back, Search, and so on, is written in C, and the Android application uses JNI. I updated my code to build for Android L and it looks like it just opens the document. However, when the back button is pressed and the document is closed, the application appears to crash and the following backtrace is displayed:

I/DEBUG   ( 1390): Abort message: 'art/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI CallIntMethodV called with pending exception 'java.lang.StackOverflowError' thrown in unknown throw location'
I/DEBUG   ( 1390): backtrace:
I/DEBUG   ( 1390):     #00 pc 000390d0  /system/lib/libc.so (tgkill+12)
I/DEBUG   ( 1390):     #01 pc 0001636d  /system/lib/libc.so (pthread_kill+64)
I/DEBUG   ( 1390):     #02 pc 00016e41  /system/lib/libc.so (raise+10)
I/DEBUG   ( 1390):     #03 pc 00013cdd  /system/lib/libc.so (__libc_android_abort+36)
I/DEBUG   ( 1390):     #04 pc 000125ac  /system/lib/libc.so (abort+4)
I/DEBUG   ( 1390):     #05 pc 00230fe9  /system/lib/libart.so (art::Runtime::Abort()+188)
I/DEBUG   ( 1390):     #06 pc 000b9571  /system/lib/libart.so     (art::LogMessage::~LogMessage()+1360)
I/DEBUG   ( 1390):     #07 pc 000c28cd  /system/lib/libart.so (art::JniAbort(char const*, char const*)+1124)
I/DEBUG   ( 1390):     #08 pc 000c2e11  /system/lib/libart.so (art::JniAbortF(char const*, char const*, ...)+68)
I/DEBUG   ( 1390):     #09 pc 000c65e9  /system/lib/libart.so (art::ScopedCheck::ScopedCheck(_JNIEnv*, int, char const*)+1952)
I/DEBUG   ( 1390):     #10 pc 000cc8eb  /system/lib/libart.so (art::CheckJNI::CallIntMethodV(_JNIEnv*, _jobject*, _jmethodID*, std::__va_list)+42)

      

When the return button is pressed when the file descriptor is assumed to be closed, CallIntMethodV is called, which is ultimately not validated by the JNI. The same code seems to work fine on dalwick. I had to add the following flags to make the JNI code compile fine for Android L preview:

-Wno-switch -Wno-sizeof-pointer-memaccess
LOCAL_DISABLE_FORMAT_STRING_CHECKS := true

      

The key point is that now it starts to fail in art but not dalwick. Any specific changes to CallIntMethodV causing a problem or compiler rigor cause such an error? Any pointers. I will be happy to provide additional details if required.

UPDATE: I temporarily disabled the file close function call that native code calls in JNI, and now I don't see the crash.

+3


source to share


1 answer


I expect this issue to be related to an issue with links - storing a local link and using it in another thread or something. I'm not sure what you mean by "native code calls in JNI to close the file", but perhaps you are passing the structure back to Java from the JNI that needs to be cleared / released (so that the VM copies data from c back to the VM).

Apparently ART has some stricter jni checks than Dalvik. There are some details on the Android site and this page then tells us how to debug them. You enable validation on a real device using adb like this:



adb shell setprop debug.checkjni 1

      

Setting it to a different value or rebooting the device will disable it.

+1


source







All Articles