My system is based on Android 11 AOSP. I’ve already implemented the following defensive checks in RenderState::postDecStrong, but during stress testing, I occasionally encounter the following null pointer error. How should I proceed with further defensive measures?
code:
void RenderState::postDecStrong(VirtualLightRefBase* object) {
if (object == NULL) {
return;
}
if (pthread_equal(mThreadId, pthread_self())) {
object->decStrong(nullptr);
} else {
// mRenderThread.queue().post([object]() { object->decStrong(nullptr); });
mRenderThread.queue().runSync([&]() { object->decStrong(nullptr); });
}
}
tombstone:
pid: 968, tid: 3119, name: RenderThread
uid: 1000
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x9
Cause: null pointer dereference
r0 00000001 r1 00000001 r2 00000000 r3 00000000
r4 b8c635b0 r5 ffbd88d0 r6 e92cb25c r7 00000000
r8 ac0a4e00 r9 00000001 r10 e903ba30 r11 ac0a4de0
ip ea43bd1c sp b5b120b0 lr e832a513 pc e832ecf8
backtrace:
#00 pc 0015fcf8 /system/lib/libhwui.so (android::uirenderer::Layer::postDecStrong()+2) (BuildId: 194a12a036e3025c31cc6d990c737e3f)
#01 pc 0015b50f /system/lib/libhwui.so (android::uirenderer::DeferredLayerUpdater::destroyLayer()+34) (BuildId: 194a12a036e3025c31cc6d990c737e3f)
#02 pc 0015bacf /system/lib/libhwui.so (android::uirenderer::DeferredLayerUpdater::detachSurfaceTexture()+12) (BuildId: 194a12a036e3025c31cc6d990c737e3f)
#03 pc 0014d993 /system/lib/libhwui.so (std::__1::packaged_task<void ()>::operator()()+50) (BuildId: 194a12a036e3025c31cc6d990c737e3f)
#04 pc 00140f6f /system/lib/libhwui.so (android::uirenderer::WorkQueue::process()+162) (BuildId: 194a12a036e3025c31cc6d990c737e3f)
#05 pc 00158161 /system/lib/libhwui.so (android::uirenderer::renderthread::RenderThread::threadLoop()+72) (BuildId: 194a12a036e3025c31cc6d990c737e3f)
#06 pc 0000ee95 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+168) (BuildId: 54518163325fdfd1b9ec8d6c1c36ab2b)
#07 pc 0000e9dd /system/lib/libutils.so (thread_data_t::trampoline(thread_data_t const*)+256) (BuildId: 54518163325fdfd1b9ec8d6c1c36ab2b)
#08 pc 000aab93 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+40) (BuildId: c958de26a3513759bb8936790e6b371b)
#09 pc 00064003 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: c958de26a3513759bb8936790e6b371b)
add null pointer check
Yuan Sean is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.