Android nativeGetString crash on API 19 - android

(I'm answering this question for future reference if anyone runs into this silly problem.)
I got this exception
07-05 17:23:49.499 1765-1765/? I/dalvikvm: #16 pc 00030ec8 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#17 pc 0002e560 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#18 pc 00063794 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+335)
#19 pc 0004ce96 /system/lib/libdvm.so
#20 pc 0004defc /system/lib/libandroid_runtime.so
#21 pc 0004ec56 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+353)
#22 pc 0000109a /system/bin/app_process
#23 pc 0000e558 /system/lib/libc.so (__libc_init+47)
at android.content.res.StringBlock.nativeGetString(Native Method)
at android.content.res.StringBlock.get(StringBlock.java:82)
at android.content.res.AssetManager.getResourceText(AssetManager.java:162)
at android.content.res.Resources.getText(Resources.java:241)
at android.content.res.Resources.getString(Resources.java:331)
at android.content.Context.getString(Context.java:358)
What could be wrong?

While it works on newer devices, on old devices (API 19, for example), you cannot have emojis as a string resource.
The offending string was:
<string formatted="false" name="common_errors_title_unexpected">OH NOES! 😢</string>
Removing the emoji fixed the issue.

Related

Android 4.4 crash signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) StringObject::utfLength() const

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)

Android ClassLoader.loadClass JNI crash

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.

How can I catch the invalid indirect refererce exception?

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)

Getting an ANR and not sure what to do

I noticed my app will get an ANR and will literally hang there until I force the app to close. I'm not doing anything really on the main thread. I am using a 3rd party Video player SDK and I believe it might be something to do with that. I get this in the logcat:
Skipped 46 frames! The application may be doing too much work on its main thread.
I was also able to get the traces.txt from the phone when it goes into the ANR state. I'm not sure what I am supposed to be looking for but this is the main thread in the traces.txt. Does anyone see anything wrong in this?
"main" prio=5 tid=1 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x4162ee40 self=0x4154f828
| sysTid=974 nice=-2 sched=0/0 cgrp=apps handle=1073942868
| state=S schedstat=( 0 0 0 ) utm=14100 stm=9716 core=0
#00 pc 00021814 /system/lib/libc.so (epoll_wait+12)
#01 pc 0001064f /system/lib/libutils.so (android::Looper::pollInner(int)+98)
#02 pc 00010879 /system/lib/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+92)
#03 pc 0006aa9d /system/lib/libandroid_runtime.so (android::NativeMessageQueue::pollOnce(_JNIEnv*, int)+22)
#04 pc 0002034c /system/lib/libdvm.so (dvmPlatformInvoke+112)
#05 pc 00050e6b /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#06 pc 000297e0 /system/lib/libdvm.so
#07 pc 00030ae8 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#08 pc 0002e180 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#09 pc 00063751 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+392)
#10 pc 0006b713 /system/lib/libdvm.so
#11 pc 000297e0 /system/lib/libdvm.so
#12 pc 00030ae8 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#13 pc 0002e180 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#14 pc 0006346d /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
#15 pc 0004ca37 /system/lib/libdvm.so
#16 pc 0004d0f7 /system/lib/libandroid_runtime.so
#17 pc 0004de1b /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+354)
#18 pc 0000105b /system/bin/app_process
#19 pc 0000e41b /system/lib/libc.so (__libc_init+50)
#20 pc 00000d7c /system/bin/app_process
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:138)
at android.os.Looper.loop(Looper.java:123)
at com.android.server.ServerThread.initAndLoop(SystemServer.java:1247)
at com.android.server.SystemServer.main(SystemServer.java:1412)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)

ResolveInfo.loadIcon causes ANR keyDispatchingTimedOut

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.

Categories

Resources