Android app crash with null pointer dereference?

I'm developing an app, and sometimes it crashes, without any cause in my code. The only thing I have in the logcat is this:

   2019-10-07 09:55:34.677 15014-15014/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-10-07 09:55:34.678 15014-15014/? A/DEBUG: Build fingerprint: 'HUAWEI/POT-LX1/HWPOT-H:9/HUAWEIPOT-L21/264C432:user/release-keys'
2019-10-07 09:55:34.678 15014-15014/? A/DEBUG: Revision: '0'
2019-10-07 09:55:34.678 15014-15014/? A/DEBUG: ABI: 'arm64'
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG: Happend: 'Mon Oct  7 09:55:34 2019
    '
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG: SYSVMTYPE: Art
    APPVMTYPE: Art
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG: pid: 14772, tid: 15007, name: pool-10-thread-  >>> com.example.myapp <<<
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x58
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG: Cause: null pointer dereference
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     x0  0000007c8c085800  x1  0000000000000001  x2  0000007d30bd3210  x3  000000000000001d
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     x4  000000000000003f  x5  0000000000000003  x6  00000000000000ff  x7  0000000000000000
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     x8  0000000000000000  x9  aeb8e5858bf8262c  x10 0000000000000060  x11 0000007c8c085870
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     x12 0000000000000000  x13 000000000000001f  x14 0000000000000c70  x15 0000000000000009
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     x16 0000007d30f1e120  x17 0000007d30bd6670  x18 0000000000000008  x19 0000007c8c085800
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     x20 0000007ca1d58ed8  x21 0000007d30bd3094  x22 0000000000000001  x23 00000000147e97f8
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     x24 0000000000000001  x25 00000000146972c8  x26 0000000000000000  x27 0000000000000066
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     x28 0000000000000066  x29 0000007c88af6860
2019-10-07 09:55:34.680 15014-15014/? A/DEBUG:     sp  0000007c88af6850  lr  0000007d30bd30cc  pc  0000007d30bd6684

BACKTRACE:

2019-10-07 09:55:34.990 15014-15014/? A/DEBUG: backtrace:
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #00 pc 0000000000455684  /system/lib64/libhwui.so (SkCanvas::restore()+20)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #01 pc 00000000004520c8  /system/lib64/libhwui.so (android::SkiaCanvas::restore()+52)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #02 pc 000000000045225c  /system/lib64/libhwui.so (android::SkiaCanvas::restoreToCount(int)+76)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #03 pc 0000000000421d78  /system/framework/arm64/boot-framework.oat (offset 0x415000) (android.graphics.Paint.nSetAlpha [DEDUPED]+72)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #04 pc 000000000004fbe8  /dev/ashmem/dalvik-jit-code-cache (deleted) (android.graphics.Canvas.restoreToCount+200)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #05 pc 00000000000a1820  /dev/ashmem/dalvik-jit-code-cache (deleted) (android.view.View.buildDrawingCacheImpl+1616)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #06 pc 00000000000a7cbc  /dev/ashmem/dalvik-jit-code-cache (deleted) (android.view.View.buildDrawingCache+332)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #07 pc 000000000056ef88  /system/lib64/libart.so (art_quick_invoke_stub+584)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #08 pc 00000000000d4204  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #09 pc 0000000000283fa8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+344)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #10 pc 000000000027dfb0  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+968)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #11 pc 000000000053ea98  /system/lib64/libart.so (MterpInvokeVirtual+588)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #12 pc 0000000000561614  /system/lib64/libart.so (ExecuteMterpImpl+14228)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #13 pc 0000000000bf4fa6  /system/framework/boot-framework.vdex (android.view.View.buildDrawingCache+2)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #14 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #15 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #16 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #17 pc 000000000053ea98  /system/lib64/libart.so (MterpInvokeVirtual+588)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #18 pc 0000000000561614  /system/lib64/libart.so (ExecuteMterpImpl+14228)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #19 pc 000000000020d214  /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.example.myapp-4SGSzZoJcONu_hs9_v1QLA==/base.apk!classes3.dex (deleted) (com.sdsmdg.harjot.materialshadows.shadowutils.ShadowGenerator.calculateAndRenderShadow)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #20 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #21 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #22 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #23 pc 000000000053fdd8  /system/lib64/libart.so (MterpInvokeDirect+296)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #24 pc 0000000000561714  /system/lib64/libart.so (ExecuteMterpImpl+14484)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #25 pc 000000000020d18c  /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.example.myapp-4SGSzZoJcONu_hs9_v1QLA==/base.apk!classes3.dex (deleted) (com.sdsmdg.harjot.materialshadows.shadowutils.ShadowGenerator.access$000)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #26 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #27 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #28 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #29 pc 000000000053ff9c  /system/lib64/libart.so (MterpInvokeStatic+204)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #30 pc 0000000000561794  /system/lib64/libart.so (ExecuteMterpImpl+14612)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #31 pc 000000000020ccc8  /dev/ashmem/dalvik-classes3.dex extracted in memory from /data/app/com.example.myapp-4SGSzZoJcONu_hs9_v1QLA==/base.apk!classes3.dex (deleted) (com.sdsmdg.harjot.materialshadows.shadowutils.ShadowGenerator$2.run+12)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #32 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #33 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #34 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #35 pc 000000000053fa14  /system/lib64/libart.so (MterpInvokeInterface+1392)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #36 pc 0000000000561814  /system/lib64/libart.so (ExecuteMterpImpl+14740)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #37 pc 000000000011fe04  /system/framework/boot.vdex (java.util.concurrent.Executors$RunnableAdapter.call+4)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #38 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #39 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #40 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #41 pc 000000000053fa14  /system/lib64/libart.so (MterpInvokeInterface+1392)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #42 pc 0000000000561814  /system/lib64/libart.so (ExecuteMterpImpl+14740)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #43 pc 00000000001213b2  /system/framework/boot.vdex (java.util.concurrent.FutureTask.run+62)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #44 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #45 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #46 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #47 pc 000000000053fa14  /system/lib64/libart.so (MterpInvokeInterface+1392)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #48 pc 0000000000561814  /system/lib64/libart.so (ExecuteMterpImpl+14740)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #49 pc 00000000001fdc94  /system/framework/boot.vdex (java.util.concurrent.ThreadPoolExecutor.processTask+146)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #50 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #51 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #52 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #53 pc 000000000053fdd8  /system/lib64/libart.so (MterpInvokeDirect+296)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #54 pc 0000000000561714  /system/lib64/libart.so (ExecuteMterpImpl+14484)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #55 pc 0000000000125f32  /system/framework/boot.vdex (java.util.concurrent.ThreadPoolExecutor.runWorker+12)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #56 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #57 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #58 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #59 pc 000000000053ea98  /system/lib64/libart.so (MterpInvokeVirtual+588)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #60 pc 0000000000561614  /system/lib64/libart.so (ExecuteMterpImpl+14228)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #61 pc 000000000012514c  /system/framework/boot.vdex (java.util.concurrent.ThreadPoolExecutor$Worker.run+4)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #62 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #63 pc 000000000025d7a8  /system/lib64/libart.so (art::interpreter::ArtInterpreterToInterpreterBridge(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame*, art::JValue*)+216)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #64 pc 000000000027df94  /system/lib64/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+940)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #65 pc 000000000053fa14  /system/lib64/libart.so (MterpInvokeInterface+1392)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #66 pc 0000000000561814  /system/lib64/libart.so (ExecuteMterpImpl+14740)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #67 pc 00000000000cd1a6  /system/framework/boot.vdex (java.lang.Thread.run+12)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #68 pc 0000000000257cb4  /system/lib64/libart.so (_ZN3art11interpreterL7ExecuteEPNS_6ThreadERKNS_20CodeItemDataAccessorERNS_11ShadowFrameENS_6JValueEb.llvm.4019025862+488)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #69 pc 000000000052aa88  /system/lib64/libart.so (artQuickToInterpreterBridge+1020)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #70 pc 00000000005780fc  /system/lib64/libart.so (art_quick_to_interpreter_bridge+92)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #71 pc 000000000056ef88  /system/lib64/libart.so (art_quick_invoke_stub+584)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #72 pc 00000000000d4204  /system/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+200)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #73 pc 0000000000472fd4  /system/lib64/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod*, art::(anonymous namespace)::ArgArray*, art::JValue*, char const*)+104)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #74 pc 0000000000474090  /system/lib64/libart.so (art::InvokeVirtualOrInterfaceWithJValues(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, jvalue*)+424)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #75 pc 000000000049f684  /system/lib64/libart.so (art::Thread::CreateCallback(void*)+1120)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #76 pc 0000000000083588  /system/lib64/libc.so (__pthread_start(void*)+36)
2019-10-07 09:55:34.991 15014-15014/? A/DEBUG:     #77 pc 00000000000241dc  /system/lib64/libc.so (__start_thread+68)

What is the problem, and how can I solve this?

Thanks!

(I'm writing these extra lines, because my post is mostly code ) (I'm writing these extra lines, because my post is mostly code)


Solution 1:

This crash only occurs when you compile with YYC, not with VM. I suggest trying to compile your app with VM instead.