The following code will cause dvmAbort() when getting package name. But the context object was the global Application object, this reference should be valid.
I want to catch this exception or resolve this crash, Who can help me?
jclass ctx_class = env->GetObjectClass(context);
>>> Backtrace <<<
#00 pc 00022184 /system/lib/libc.so (tgkill+12)
#01 pc 000131d9 /system/lib/libc.so (pthread_kill+48)
#02 pc 000133ed /system/lib/libc.so (raise+10)
#03 pc 00012123 /system/lib/libc.so (?+0)
#04 pc 00021a38 /system/lib/libc.so (abort+4)
#05 pc 00048c9f /system/lib/libdvm.so (dvmAbort+78)
#06 pc 0004d607 /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*, _jobject*)+146)
#07 pc 0005018b /system/lib/libdvm.so (?+0)
#10 pc 000204cc /system/lib/libdvm.so (dvmPlatformInvoke+112)
#11 pc 00051157 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#12 pc 00052b41 /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*)+184)
#13 pc 00029960 /system/lib/libdvm.so (?+0)
#14 pc 00030dec /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#15 pc 0002e484 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#16 pc 000635b9 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
#17 pc 000635dd /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#18 pc 000582bb /system/lib/libdvm.so (?+0)
#19 pc 0000d2c8 /system/lib/libc.so (__thread_entry+72)
#20 pc 0000d460 /system/lib/libc.so (pthread_create+240)
Related
Facing this issue. Unable to reproduce but getting these crashes in google play console after our latest release. Please help. Only effecting Android 4.4. More than 1700 reports this week.
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
StringObject::utfLength() const
backtrace:
native: pc 000000000005596c /system/lib/libdvm.so (StringObject::utfLength() const+17)
native: pc 000000000004b6e5 /system/lib/libdvm.so
native: pc 0000000000017341 /system/lib/libjavacore.so
native: pc 00000000000174e7 /system/lib/libjavacore.so
native: pc 000000000001dd8c /system/lib/libdvm.so (dvmPlatformInvoke+112)
native: pc 000000000004e253 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
native: pc 00000000000271a0 /system/lib/libdvm.so
native: pc 000000000002e150 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
native: pc 000000000002b7fc /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
native: pc 0000000000060843 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+338)
native: pc 0000000000060867 /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
native: pc 0000000000055547 /system/lib/libdvm.so
native: pc 000000000000d280 /system/lib/libc.so (__thread_entry+72)
native: pc 000000000000d41c /system/lib/libc.so (pthread_create+240)
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadd00d
#00 pc 0x50f8e /system/lib/libdvm.so (dvmAbort+89)
#01 pc 0x59ee1 /system/lib/libdvm.so (dvmLinearAlloc(Object*, unsigned int)+64)
#02 pc 0x76a7b /system/lib/libdvm.so (???)
#03 pc 0x76d77 /system/lib/libdvm.so (dvmDefineClass(DvmDex*, char const*, Object*)+10)
#04 pc 0x71583 /system/lib/libdvm.so (???)
#05 pc 0x30c0c /system/lib/libdvm.so (???)
#06 pc 0x343dc /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#07 pc 0x6d109 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+284)
#08 pc 0x6d12d /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
#09 pc 0x76e69 /system/lib/libdvm.so (dvmFindClassNoInit(char const*, Object*)+108)
#10 pc 0x6216b /system/lib/libdvm.so (???)
#11 pc 0x62287 /system/lib/libdvm.so (???)
#12 pc 0x65a6d /system/lib/libdvm.so (dvmVerifyCodeFlow(VerifierData*)+9760)
#13 pc 0x68c91 /system/lib/libdvm.so (???)
#14 pc 0x68ce3 /system/lib/libdvm.so (dvmVerifyClass(ClassObject*)+42)
#15 pc 0x7704d /system/lib/libdvm.so (dvmInitClass+116)
#16 pc 0x742d1 /system/lib/libdvm.so (???)
#17 pc 0x30c0c /system/lib/libdvm.so (???)
#18 pc 0x343dc /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#19 pc 0x6ce39 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+344)
#20 pc 0x73b19 /system/lib/libdvm.so (???)
#21 pc 0x30c0c /system/lib/libdvm.so (???)
#22 pc 0x343dc /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#23 pc 0x6ce39 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+344)
#24 pc 0x7431b /system/lib/libdvm.so (???)
#25 pc 0x30c0c /system/lib/libdvm.so (???)
#26 pc 0x343dc /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#27 pc 0x6d109 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+284)
#28 pc 0x554af /system/lib/libdvm.so (???)
#29 pc 0x48c6b /system/lib/libandroid_runtime.so (???)
#30 pc 0x4a81f /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+394)
#31 pc 0xf0d /system/bin/app_process (???)
java.lang.Throwable:
******* Java stack for JNI crash *******
at dalvik.system.DexFile.defineClass(Native Method)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:195)
at dalvik.system.DexPathList.findClass(DexPathList.java:315)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:58)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.lily.dexLoader.invokeStaticMethod(SourceFile:70)
at com.lily.sdk.Web.<init>(SourceFile:77)
......
I can not reproduce this crash through my android app, but the monitor system reports this kind of crash many times.
It is not clear whether the dex is broken or the system dalvik is not stable.
Does anyone has any experience on this kind of loadClass crash?
If the VM detects a serious problem, it will send diagnostics to the log, and abort. The VM in the version of Android you're using crashes itself by attempting to write to a read-only location (0xdeadd00d).
Looking at the stack trace, the last thing before dvmAbort() is dvmLinearAlloc(). Looking at a recent source file, the VM will abort in that function if it runs out of memory to allocate, or if it's unable to change the permissions on a page while in a special debug mode where pages are aggressively marked read-only. It's almost certainly the former. Looking at the logcat output would tell you for sure.
Assuming you're running out of memory, I'd guess you're running an old version of Android (<= gingerbread), where the "linear alloc" buffer was under-sized. This region of memory is used to hold class meta-data, such as tables of methods and fields, but not the data itself (which is why it can be marked read-only to help hunt for memory trashers). The only way to avoid the problem is to restructure the classes.
You can read more about the problem, and a solution deployed by Facebook engineers, in this blog post.
SIGSEGV: SIGSEGV
#00 pc 4009a4c0 /system/bin/linker
#01 pc 4009b004 /system/bin/linker
#02 pc 4009b416 /system/bin/linker
#03 pc 4009b9ca /system/bin/linker
#04 pc 40099f42 /system/bin/linker
#05 pc 00051074 /system/lib/libdvm.so (_Z17dvmLoadNativeCodePKcP6ObjectPPc)
#06 pc 00068a18 /system/lib/libdvm.so
#07 pc 00027fa0 /system/lib/libdvm.so
#08 pc 0002f110 /system/lib/libdvm.so (_Z11dvmMterpStdP6Thread)
#09 pc 0002c774 /system/lib/libdvm.so (_Z12dvmInterpretP6ThreadPK6MethodP6JValue)
#10 pc 000619ea /system/lib/libdvm.so (_Z15dvmInvokeMethodP6ObjectPK6MethodP11ArrayObjectS5_P11ClassObjectb)
#11 pc 00069af6 /system/lib/libdvm.so
#12 pc 00027fa0 /system/lib/libdvm.so
#13 pc 0002f110 /system/lib/libdvm.so (_Z11dvmMterpStdP6Thread)
#14 pc 0002c774 /system/lib/libdvm.so (_Z12dvmInterpretP6ThreadPK6MethodP6JValue)
#15 pc 000619ea /system/lib/libdvm.so (_Z15dvmInvokeMethodP6ObjectPK6MethodP11ArrayObjectS5_P11ClassObjectb)
#16 pc 00069af6 /system/lib/libdvm.so
#17 pc 00027fa0 /system/lib/libdvm.so
#18 pc 0002f110 /system/lib/libdvm.so (_Z11dvmMterpStdP6Thread)
#19 pc 0002c774 /system/lib/libdvm.so (_Z12dvmInterpretP6ThreadPK6MethodP6JValue)
#20 pc 000619ea /system/lib/libdvm.so (_Z15dvmInvokeMethodP6ObjectPK6MethodP11ArrayObjectS5_P11ClassObjectb)
#21 pc 00069af6 /system/lib/libdvm.so
#22 pc 00027fa0 /system/lib/libdvm.so
#23 pc 0002f110 /system/lib/libdvm.so (_Z11dvmMterpStdP6Thread)
#24 pc 0002c774 /system/lib/libdvm.so (_Z12dvmInterpretP6ThreadPK6MethodP6JValue)
#25 pc 00061706 /system/lib/libdvm.so (_Z14dvmCallMethodVP6ThreadPK6MethodP6ObjectbP6JValueSt9__va_list)
#26 pc 0004ae1a /system/lib/libdvm.so
#27 pc 00050546 /system/lib/libandroid_runtime.so
#28 pc 000512d2 /system/lib/libandroid_runtime.so (_ZN7android14AndroidRuntime5startEPKcS2_)
#29 pc 4009605c /system/bin/app_process
#30 pc 0000e5e6 /system/lib/libc.so (__libc_init)
java:
java.lang.Runtime.nativeLoad(Native Method)
java.lang.Runtime.doLoad(Runtime.java:421)
java.lang.Runtime.load(Runtime.java:331)
java.lang.System.load(System.java:541)
....
It crashes at this line when trying to load a private library(.so):
System.load(so_path);
In addition, this code is invoked from a customized DexClassLoader, which loads a lot of private classes in associated with the native code in ".so".
However on most devices it is loaded regularly. And this issue is mostly found on devices with android api level 17, 16, 19.
Does any one have any experience or any idea about this issue? Thank you very much!
can anyone let me know what does this backtrace log indicates . i am spawning a thread in my code .but i am not able to undrstand what is wrong with that.
Thread creation code
pthread_create(&tid, &attr, (void*()(void))threadFunc, arg);
>I/DEBUG ( 6144): backtrace:
>I/DEBUG ( 6144): #00 pc 00014260 /system/lib/libc.so (dlmalloc+643)
>I/DEBUG ( 6144): #01 pc 00016f7f /system/lib/libc.so (malloc+10)
>I/DEBUG ( 6144): #02 pc 00061797 /system/lib/libdvm.so (dvmJdwpPostLocationEvent(JdwpState*, JdwpLocation const*, unsigned long long, int)+124)
I/DEBUG ( 6144): #03 pc 000438e1 /system/lib/libdvm.so (dvmDbgPostLocationEvent(Method const*, int, Object*, int)+76)
I/DEBUG ( 6144): #04 pc 0002b940 /system/lib/libdvm.so (dvmCheckBefore+504)
I/DEBUG ( 6144): #05 pc 0001e37c /system/lib/libdvm.so
I/DEBUG ( 6144): #06 pc 0002bba8 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+180)
I/DEBUG ( 6144): #07 pc 0005f831 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
I/DEBUG ( 6144): #08 pc 0005f85b /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
I/DEBUG ( 6144): #09 pc 00054413 /system/lib/libdvm.so
I/DEBUG ( 6144): #10 pc 00012e00 /system/lib/libc.so (__thread_entry+48)
I/DEBUG ( 6144): #11 pc 00012558 /system/lib/libc.so (pthread_create+172)
Thank You
Are you sure that this happens due pthread_create? Try to use ndk-stack command(from NDK) to find out the root cause(or android-ndk-stacktrace-analyzer):
adb logcat | ndk-stack -sym /path_to_your_project/obj/local/armeabi
One of my class retrieves the list of the activities installed on the device and their icons. That works perfectly well on numerous phones but one of my users using a Nexus 7 got an ANR :
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x410a39a0 self=0x400d3010
| sysTid=15890 nice=0 sched=0/0 cgrp=apps handle=1075213276
| state=D schedstat=( 2274319000 316147000 1599 ) utm=146 stm=81 core=0
#00 pc 00016d78 /system/lib/libc.so (read+12)
#01 pc 00012b3f /system/lib/libutils.so (android::ZipFileRO::mapCentralDirectory()+114)
#02 pc 00012fe7 /system/lib/libutils.so (android::ZipFileRO::open(char const*)+126)
#03 pc 0001765d /system/lib/libandroidfw.so (android::AssetManager::SharedZip::SharedZip(android::String8 const&, long)+92)
#04 pc 00018129 /system/lib/libandroidfw.so (android::AssetManager::SharedZip::get(android::String8 const&)+232)
#05 pc 000181e9 /system/lib/libandroidfw.so (android::AssetManager::ZipSet::getZipResourceTableAsset(android::String8 const&)+32)
#06 pc 00018a6d /system/lib/libandroidfw.so (android::AssetManager::getResTable(bool) const+124)
#07 pc 0006451f /system/lib/libandroid_runtime.so
#08 pc 0001e290 /system/lib/libdvm.so (dvmPlatformInvoke+112)
#09 pc 0004d411 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+396)
#10 pc 000276a0 /system/lib/libdvm.so
#11 pc 0002b57c /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#12 pc 0005ff07 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+374)
#13 pc 00066f95 /system/lib/libdvm.so
#14 pc 000276a0 /system/lib/libdvm.so
#15 pc 0002b57c /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#16 pc 0005ff07 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+374)
#17 pc 000677e1 /system/lib/libdvm.so
#18 pc 000276a0 /system/lib/libdvm.so
#19 pc 0002b57c /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#20 pc 0005fc31 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
#21 pc 000499fb /system/lib/libdvm.so
#22 pc 00046871 /system/lib/libandroid_runtime.so
#23 pc 00047533 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+390)
#24 pc 00000db7 /system/bin/app_process
#25 pc 0001271f /system/lib/libc.so (__libc_init+38)
#26 pc 00000ae8 /system/bin/app_process
at android.content.res.AssetManager.getStringBlockCount(Native Method)
at android.content.res.AssetManager.makeStringBlocks(AssetManager.java:257)
at android.content.res.AssetManager.ensureStringBlocks(AssetManager.java:249)
at android.content.res.Resources.<init>(Resources.java:189)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1705)
at android.app.ActivityThread.getTopLevelResources(ActivityThread.java:1734)
at android.app.ApplicationPackageManager.getResourcesForApplication(ApplicationPackageManager.java:746)
at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:636)
at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:140)
at android.content.pm.ComponentInfo.loadDefaultIcon(ComponentInfo.java:161)
at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:145)
at android.content.pm.ResolveInfo.loadIcon(ResolveInfo.java:186)
It seems like the ANR is caused by ResolveInfo.loadIcon when I try to retrieve the activity icon...
Any idea why it could be caused on one device and not others ? Maybe one of his app is not correctly installed or something like this...
Thanks for your time.