KeepSafe / ReLinker

A robust native library loader for Android.
Apache License 2.0
3.23k stars 371 forks source link

Unable to load library from file path #61

Open srikanthsunkari opened 5 years ago

srikanthsunkari commented 5 years ago

Well I have checkout the #58 from @artyomd, but failing to load the native library from dataDirectory.


A/art: art/runtime/java_vm_ext.cc:475] JNI DETECTED ERROR IN APPLICATION: JNI RegisterNatives called with pending exception java.lang.ExceptionInInitializerError: 
A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String) (Runtime.java:-2)
A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.String java.lang.Runtime.doLoad(java.lang.String, java.lang.ClassLoader) (Runtime.java:1072)
A/art: art/runtime/java_vm_ext.cc:475]   at void java.lang.Runtime.load0(java.lang.Class, java.lang.String) (Runtime.java:906)
A/art: art/runtime/java_vm_ext.cc:475]   at void java.lang.System.load(java.lang.String) (System.java:1537)
A/art: art/runtime/java_vm_ext.cc:475]   at void com.getkeepsafe.relinker.SystemLibraryLoader.loadPath(java.lang.String) (SystemLibraryLoader.java:29)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.getkeepsafe.relinker.ReLinkerInstance.loadInternal(android.content.Context, java.io.File) (ReLinkerInstance.java:250)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.getkeepsafe.relinker.ReLinkerInstance.access$100(com.getkeepsafe.relinker.ReLinkerInstance, android.content.Context, java.io.File) (ReLinkerInstance.java:31)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void com.getkeepsafe.relinker.ReLinkerInstance$2.run() (ReLinkerInstance.java:191)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at void java.lang.Thread.run() (Thread.java:760)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475] 
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]     in call to RegisterNatives
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]     from java.lang.String java.lang.Runtime.nativeLoad(java.lang.String, java.lang.ClassLoader, java.lang.String)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475] "Thread-53" prio=5 tid=64 Runnable
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | group="main" sCount=0 dsCount=0 obj=0x12ec9700 self=0xc5583f00
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | sysTid=26890 nice=0 cgrp=default sched=0/0 handle=0xb297a920
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | state=R schedstat=( 4651665 8239268 26 ) utm=0 stm=0 core=2 HZ=100
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | stack=0xb2878000-0xb287a000 stackSize=1038KB
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   | held mutexes= "mutator lock"(shared held)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #00 pc 00352411  /system/lib/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+128)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #01 pc 00332569  /system/lib/libart.so (_ZNK3art6Thread9DumpStackERNSt3__113basic_ostreamIcNS1_11char_traitsIcEEEEbP12BacktraceMap+308)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #02 pc 0023a825  /system/lib/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+848)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #03 pc 0023ad47  /system/lib/libart.so (_ZN3art9JavaVMExt9JniAbortVEPKcS2_St9__va_list+58)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #04 pc 000cb09b  /system/lib/libart.so (_ZN3art11ScopedCheck6AbortFEPKcz+46)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #05 pc 000cac87  /system/lib/libart.so (_ZN3art11ScopedCheck11CheckThreadEP7_JNIEnv+362)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #06 pc 000c9c9f  /system/lib/libart.so (_ZN3art11ScopedCheck22CheckPossibleHeapValueERNS_18ScopedObjectAccessEcNS_12JniValueTypeE+26)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #07 pc 000c917b  /system/lib/libart.so (_ZN3art11ScopedCheck5CheckERNS_18ScopedObjectAccessEbPKcPNS_12JniValueTypeE+802)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #08 pc 000c678d  /system/lib/libart.so (_ZN3art8CheckJNI15RegisterNativesEP7_JNIEnvP7_jclassPK15JNINativeMethodi+464)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #09 pc 0000d90b  /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a/libfb.so (_ZN8facebook3jni15CountableOnLoadEP7_JNIEnv+62)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #10 pc 000153d9  /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a/libfb.so (_Z16initialize_fbjniv+8)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #11 pc 000132b7  /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a/libfb.so (_ZN8facebook3jni10initializeEP7_JavaVMONSt6__ndk18functionIFvvEEE+90)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #12 pc 00017829  /data/data/com.sample.preprod/app_libs/sample/libs/armeabi-v7a/libfb.so (JNI_OnLoad+32)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #13 pc 0023c835  /system/lib/libart.so (_ZN3art9JavaVMExt17LoadNativeLibraryEP7_JNIEnvRKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEEP8_jobjectP8_jstringPS9_+1844)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #14 pc 00003167  /system/lib/libopenjdkjvm.so (JVM_NativeLoad+178)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   native: #15 pc 00068c6d  /system/framework/arm/boot.oat (Java_java_lang_Runtime_nativeLoad__Ljava_lang_String_2Ljava_lang_ClassLoader_2Ljava_lang_String_2+144)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.Runtime.nativeLoad(Native method)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.Runtime.doLoad(Runtime.java:1072)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   - locked <0x03d4240b> (a java.lang.Runtime)
2019-05-16 17:34:52.781 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.Runtime.load0(Runtime.java:906)
2019-05-16 17:34:52.782 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   - locked <0x03d4240b> (a java.lang.Runtime)
2019-05-16 17:34:52.782 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.System.load(System.java:1537)
2019-05-16 17:34:52.782 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.getkeepsafe.relinker.SystemLibraryLoader.loadPath(SystemLibraryLoader.java:29)
2019-05-16 17:34:52.782 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.getkeepsafe.relinker.ReLinkerInstance.loadInternal(ReLinkerInstance.java:250)
2019-05-16 17:34:52.782 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.getkeepsafe.relinker.ReLinkerInstance.access$100(ReLinkerInstance.java:31)
2019-05-16 17:34:52.782 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at com.getkeepsafe.relinker.ReLinkerInstance$2.run(ReLinkerInstance.java:191)
2019-05-16 17:34:52.782 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475]   at java.lang.Thread.run(Thread.java:760)
2019-05-16 17:34:52.782 26411-26890/com.sample.preprod A/art: art/runtime/java_vm_ext.cc:475] 

Any help is appreciated.

benjamin-bader commented 5 years ago

This isn't a relinker error, something is wrong with the JNI initialization in the native library itself. If this is your own code, then you'll need to fix it yourself, otherwise file a bug report with whomever distributed it. We can't help.

srikanthsunkari commented 5 years ago

Sure, This is not my code. It is one of my third-party libraries, I have no clue why this crash happened. But when I am packaging the so files with the APK, I did not observe this crash. It only occurs when I load the libraries from Activity.getDir("libs") path. Is this related to any integration issue ? I looked in both repo's didn't find usage of Relinker.load(context, file) with library file path Can you please provide an example usage of Relinker.load(context, file) method, to cross verify from my end in between. Thanks.