华为运行APK时的ART空指针间接引用报错问题

Posted 疯狂小芋头

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了华为运行APK时的ART空指针间接引用报错问题相关的知识,希望对你有一定的参考价值。

文章目录

1. 问题情况

在此前已经正常运行过的项目,重新修改了配置信息(gradle和一些业务环境信息如域名等)后重新运行时,运行后若干秒后会发生闪退并输出了以下的错误信息。并且该错误在华为系统上产生,但在三星、魅族的手机上并不会闪退也没有输出类似的错误信息。

    --------- beginning of crash
2021-09-03 17:58:37.942 5159-9215/xxx A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8 in tid 9215 (HeapTaskDaemon), pid 5159 (xxx)
2021-09-03 17:58:37.952 2621-3203/? E/BoosterNty: onOemHookRawEvent decodes failed.
2021-09-03 17:58:38.061 10145-10145/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2021-09-03 17:58:38.061 10145-10145/? A/DEBUG: Build fingerprint: 'HUAWEI/ELS-TN00/HWELS:10/HUAWEIELS-TN00/102.0.0.166C01:user/release-keys'
2021-09-03 17:58:38.061 10145-10145/? A/DEBUG: Revision: '0'
2021-09-03 17:58:38.061 10145-10145/? A/DEBUG: ABI: 'arm'
2021-09-03 17:58:38.063 10145-10145/? A/DEBUG: SYSVMTYPE: Maple
    APPVMTYPE: Art
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG: Timestamp: 2021-09-03 17:58:38+0800
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG: pid: 5159, tid: 9215, name: HeapTaskDaemon  >>> xxx <<<
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG: uid: 10398
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x8
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG: Cause: null pointer dereference
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG:     r0  00000000  r1  de5ff5e0  r2  00000004  r3  42c00000
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG:     r4  000012b4  r5  70560020  r6  70b2c648  r7  70b2d8e8
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG:     r8  70b2c634  r9  de5ff5e0  r10 f237817c  r11 00002028
2021-09-03 17:58:38.064 10145-10145/? A/DEBUG:     ip  00000000  sp  de5ff580  lr  edc552f3  pc  edc552d6
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG: backtrace:
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #00 pc 001922d6  /apex/com.android.runtime/lib/libart.so (_ZN3art6mirror6Object15VisitReferencesILb1ELNS_17VerifyObjectFlagsE0ELNS_17ReadBarrierOptionE1ENS_2gc9collector17ConcurrentCopying16RefFieldsVisitorILb0EEES9_EEvRKT2_RKT3_+2046) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #01 pc 00186243  /apex/com.android.runtime/lib/libart.so (art::gc::collector::ConcurrentCopying::ImmuneSpaceScanObjVisitor::Callback(art::mirror::Object*, void*)+70) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #02 pc 001795d3  /apex/com.android.runtime/lib/libart.so (art::gc::accounting::ModUnionTableReferenceCache::VisitObjects(void (*)(art::mirror::Object*, void*), void*)+162) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #03 pc 0018262b  /apex/com.android.runtime/lib/libart.so (art::gc::collector::ConcurrentCopying::CopyingPhase()+758) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #04 pc 00180ef7  /apex/com.android.runtime/lib/libart.so (art::gc::collector::ConcurrentCopying::RunPhases()+910) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #05 pc 0019746f  /apex/com.android.runtime/lib/libart.so (art::gc::collector::GarbageCollector::Run(art::gc::GcCause, bool)+214) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #06 pc 001ae775  /apex/com.android.runtime/lib/libart.so (art::gc::Heap::CollectGarbageInternal(art::gc::collector::GcType, art::gc::GcCause, bool)+1980) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #10 pc 0006593b  /system/framework/arm/boot-core-libart.oat (art_jni_trampoline+74) (BuildId: 3d8e583473f760921aa1a8aa5c3209f4e8ba7bd1)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #11 pc 000e3bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #12 pc 004558bb  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #16 pc 0044aa71  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+584) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #17 pc 000de814  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #18 pc 001b4bba  /apex/com.android.runtime/javalib/core-libart.jar (java.lang.Daemons$HeapTaskDaemon.runInternal+38)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #19 pc 0044acc9  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1184) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #20 pc 000de814  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #21 pc 001b439e  /apex/com.android.runtime/javalib/core-libart.jar (java.lang.Daemons$Daemon.run+50)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #22 pc 0044c1e5  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+1468) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #23 pc 000dea14  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #27 pc 0043ed29  /apex/com.android.runtime/lib/libart.so (artQuickToInterpreterBridge+832) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #28 pc 000e85a1  /apex/com.android.runtime/lib/libart.so (art_quick_to_interpreter_bridge+32) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #29 pc 000e3bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #30 pc 004558bb  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #32 pc 003932bb  /apex/com.android.runtime/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+54) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.167 10145-10145/? A/DEBUG:       #33 pc 00393fc5  /apex/com.android.runtime/lib/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue const*)+300) (BuildId: f19139b4309180c887ec6b2ca9af235c)
2021-09-03 17:58:38.579 5159-5159/xxx E/RtgSchedManager: endActivityTransaction: margin state not match
2021-09-03 17:58:38.559 1111-1111/? E//system/bin/tombstoned: Tombstone written to: /data/tombstones/tombstone_00
2021-09-03 17:58:38.596 30804-30804/? E/RtgSchedManager: endActivityTransaction: margin state not match
2021-09-03 17:58:38.620 30804-31290/? E/AbilityFormHost: startListening [0ms]
2021-09-03 17:58:38.649 2621-3203/? E/DollieAdapterService: notifyActivityState pkg:com.huawei.android.launcher/com.huawei.android.launcher.drawer.DrawerLauncher state:2 fg:true mUid:10079
2021-09-03 17:58:38.652 2621-3203/? E/SmartDualCardConfig: isAppInBlackList false,items==null
2021-09-03 17:58:38.680 1690-1741/? E/WindowManager: icon is null!!
2021-09-03 17:58:38.681 1690-1741/? E/WindowManager: icon is null!!
2021-09-03 17:58:38.688 30804-31348/? E/TaskKeyCache: Unexpected null key or value: id=10862 windowingMode=1 user=0 lastActiveTime=1436632319, null
2021-09-03 17:58:38.703 30804-30804/? E/HwLauncher: NegativeScreenClientCallBack  onServiceStateChanged overlayAttached = true mServiceState = 0
2021-09-03 17:58:38.706 18469-18812/? E/ContentValues: Cannot parse Integer value at key value
2021-09-03 17:58:38.742 2878-5320/? E/AwareLog: HwProcessObserver: Get package name failed for pid:5159

根据以上的错误信息,可以知道是在ART的处理中出现了Cause: null pointer dereference这个错误,该错查阅一下资料可以知道空指针间接引用的问题

由于能找到的所有的华为系统手机运行时都有这个问题,但是其它品牌的手机确实也不会有问题,并且问题的产生是在ART的so库,初步估计跟应用的业务是没有关系的。但是接下来诡异的情况就来了。

在偶然的情况下,发现应用并不会闪退,再三测试和验证后发现,如果连接着USB线,应用启动后就会出现闪退的情况;如果不连接着USB线,就不会发生闪退。当时就一脸懵逼???这是什么操作?
但是再三测试后确实是如此的。这就更加证明跟应用业务逻辑是没有关系的,但是问题是出在哪无法确认。这时考虑是否是AS的影响呢?因为AS已经运行了很久并且是反复切换了大量的项目不确定是否与AS的一些运行状态或缓存有关,重启了AS后,该问题不再出现。

暂时还不知道原因是什么,先记录一下以供后续参考。

以上是关于华为运行APK时的ART空指针间接引用报错问题的主要内容,如果未能解决你的问题,请参考以下文章

华为运行APK时的ART空指针间接引用报错问题

华为运行APK时的ART空指针间接引用报错问题

空类型指针(void *)的理解

c++异步回调函数引用传递空指针异常

引用还是指针?

获得额外意图时的空指针