newbie_coder
newbie_coder

Reputation: 285

I'm getting a native crash in my application. This crash is frequent in the release build and has never occurred in debug

I tried looking into the systrace in Perfetto UI but just couldn't figure out the reason for crash. The logs for the crashes showed multiple calls related to the G.C so suspected it to be a memory leak and used LeakCanary to look for memory leaks. I'm fixing the memory leaks one by one. Just wanted to know if I'm heading in the right direction or not.

This is the crash that I'm getting

755 31581 31581 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-01 12:25:34.755 31581 31581 F DEBUG   : Build fingerprint: 'motorola/corfur_g/corfur:12/S2RUBS32.51-15-9-11/dd8d5-e81484:user/release-keys'
12-01 12:25:34.755 31581 31581 F DEBUG   : Revision: 'pvt'
12-01 12:25:34.755 31581 31581 F DEBUG   : ABI: 'arm64'
12-01 12:25:34.755 31581 31581 F DEBUG   : Timestamp: 2023-12-01 12:25:33.994708494+0530
12-01 12:25:34.755 31581 31581 F DEBUG   : Process uptime: 0s
12-01 12:25:34.755 31581 31581 F DEBUG   : Cmdline: in.myapp.qa
12-01 12:25:34.755 31581 31581 F DEBUG   : pid: 28827, tid: 28836, name: HeapTaskDaemon  >>> in.myapp.qa <<<
12-01 12:25:34.755 31581 31581 F DEBUG   : uid: 11318
12-01 12:25:34.755 31581 31581 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
12-01 12:25:34.755 31581 31581 F DEBUG   : Abort message: 'klass pointer for ref: 0x13708ed0 found to be null.'
12-01 12:25:34.755 31581 31581 F DEBUG   :     x0  0000000000000000  x1  00000000000070a4  x2  0000000000000006  x3  00000076aeb800b0
12-01 12:25:34.755 31581 31581 F DEBUG   :     x4  35312f6036772f1f  x5  35312f6036772f1f  x6  35312f6036772f1f  x7  7f7f7f7f7f7f7f7f
12-01 12:25:34.755 31581 31581 F DEBUG   :     x8  00000000000000f0  x9  a219e6e01d251e00  x10 0000000000000000  x11 ffffff80fffffbdf
12-01 12:25:34.755 31581 31581 F DEBUG   :     x12 0000000000000001  x13 000000000000074a  x14 00000076aeb7eeb0  x15 0000000034155555
12-01 12:25:34.755 31581 31581 F DEBUG   :     x16 00000079d1400060  x17 00000079d13dc4b0  x18 0000007654b9a000  x19 000000000000709b
12-01 12:25:34.755 31581 31581 F DEBUG   :     x20 00000000000070a4  x21 00000000ffffffff  x22 000000000000000b  x23 00000076be2a3fbe
12-01 12:25:34.755 31581 31581 F DEBUG   :     x24 000000000000000b  x25 0000000000000002  x26 0000000000000001  x27 00000076bee16000
12-01 12:25:34.755 31581 31581 F DEBUG   :     x28 b4000076e116c3e0  x29 00000076aeb80130
12-01 12:25:34.755 31581 31581 F DEBUG   :     lr  00000079d138c8b0  sp  00000076aeb80090  pc  00000079d138c8dc  pst 0000000000001000
12-01 12:25:34.755 31581 31581 F DEBUG   : backtrace:
12-01 12:25:34.755 31581 31581 F DEBUG   :       #00 pc 00000000000518dc  /apex/com.android.runtime/lib64/bionic/libc.so (abort+168) (BuildId: 37a328c30fb8c595fc3ebc7c80be6ac1)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #01 pc 00000000007716f0  /apex/com.android.art/lib64/libart.so (art::Runtime::Abort(char const*)+904) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #02 pc 00000000000357d0  /apex/com.google.mainline.primary.libs@341050000/lib64/libbase.so/75d3253827fcfd7a8d7b02ad45991611ec4ca424c0278e13e8acfad4d14e597a3ecff6c0caa2b785c73838528ee6e9c2b313240ff895f50ee39b1d7bc10f390a/libbase.so (android::base::SetAborter(std::__1::function<void (char const*)>&&)::$_0::__invoke(char const*)+80) (BuildId: 6f67f69ff36b970d0b831cfdab3b578d)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #03 pc 0000000000034d58  /apex/com.google.mainline.primary.libs@341050000/lib64/libbase.so/75d3253827fcfd7a8d7b02ad45991611ec4ca424c0278e13e8acfad4d14e597a3ecff6c0caa2b785c73838528ee6e9c2b313240ff895f50ee39b1d7bc10f390a/libbase.so (android::base::LogMessage::~LogMessage()+352) (BuildId: 6f67f69ff36b970d0b831cfdab3b578d)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #04 pc 0000000000207734  /apex/com.android.art/lib64/libart.so (art::gc::Verification::LogHeapCorruption(art::ObjPtr<art::mirror::Object>, art::MemberOffset, art::mirror::Object*, bool) const+2016) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #05 pc 00000000002aa950  /apex/com.android.art/lib64/libart.so (void art::mirror::Object::VisitReferences<true, (art::VerifyObjectFlags)0, (art::ReadBarrierOption)1, art::gc::collector::ConcurrentCopying::ComputeLiveBytesAndMarkRefFieldsVisitor<true>, art::gc::collector::ConcurrentCopying::ComputeLiveBytesAndMarkRefFieldsVisitor<true> >(art::gc::collector::ConcurrentCopying::ComputeLiveBytesAndMarkRefFieldsVisitor<true> const&, art::gc::collector::ConcurrentCopying::ComputeLiveBytesAndMarkRefFieldsVisitor<true> const&)+2240) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #06 pc 00000000002a9f9c  /apex/com.android.art/lib64/libart.so (art::gc::collector::ConcurrentCopying::ProcessMarkStackForMarkingAndComputeLiveBytes()+1820) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #07 pc 00000000002a67e0  /apex/com.android.art/lib64/libart.so (art::gc::collector::ConcurrentCopying::MarkingPhase()+1188) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #08 pc 00000000002a13d0  /apex/com.android.art/lib64/libart.so (art::gc::collector::ConcurrentCopying::RunPhases()+184) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #09 pc 00000000003a6a10  /apex/com.android.art/lib64/libart.so (art::gc::collector::GarbageCollector::Run(art::gc::GcCause, bool)+312) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #10 pc 00000000003a2ea0  /apex/com.android.art/lib64/libart.so (art::gc::Heap::CollectGarbageInternal(art::gc::collector::GcType, art::gc::GcCause, bool, unsigned int)+548) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #11 pc 00000000003a2748  /apex/com.android.art/lib64/libart.so (art::gc::Heap::ConcurrentGC(art::Thread*, art::gc::GcCause, bool, unsigned int)+188) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #12 pc 00000000003a25cc  /apex/com.android.art/lib64/libart.so (art::gc::Heap::ConcurrentGCTask::Run(art::Thread*)+72) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.755 31581 31581 F DEBUG   :       #13 pc 00000000003a06d0  /apex/com.android.art/lib64/libart.so (art::gc::TaskProcessor::RunAllTasks(art::Thread*)+72) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #14 pc 000000000034aa30  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #15 pc 0000000000333fa4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #16 pc 0000000000511078  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+1976) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #17 pc 000000000049e100  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+960) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #18 pc 000000000034d1d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #19 pc 000000000002bad0  /apex/com.android.art/javalib/core-libart.jar (java.lang.Daemons$HeapTaskDaemon.runInternal+0)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #20 pc 0000000000378bb0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.11907307138045539842)+232) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #21 pc 0000000000511d44  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #22 pc 000000000049e100  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+960) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #23 pc 000000000034d1d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #24 pc 000000000002adfc  /apex/com.android.art/javalib/core-libart.jar (java.lang.Daemons$Daemon.run+0)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #25 pc 0000000000378bb0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.11907307138045539842)+232) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #26 pc 0000000000511d44  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #27 pc 000000000049efac  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+4716) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #28 pc 000000000034d1d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #29 pc 000000000010eaf0  /apex/com.android.art/javalib/core-oj.jar (java.lang.Thread.run+0)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #30 pc 0000000000378bb0  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.11907307138045539842)+232) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #31 pc 00000000003784a8  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+964) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #32 pc 000000000034ab68  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #33 pc 0000000000333fa4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #34 pc 000000000023e4d4  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+144) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #35 pc 0000000000539a3c  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1600) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #36 pc 00000000000b6974  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+264) (BuildId: 37a328c30fb8c595fc3ebc7c80be6ac1)
12-01 12:25:34.756 31581 31581 F DEBUG   :       #37 pc 0000000000053210  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (BuildId: 37a328c30fb8c595fc3ebc7c80be6ac1)

Upvotes: 1

Views: 2532

Answers (2)

Pierre-Yves Ricau
Pierre-Yves Ricau

Reputation: 8349

  • InboxActivity received the Activity.onDestroy() callback, it should be garbage collected but cannot be because it is held in memory ("leaking").
  • It is held in memory by android.app.LoaderApk.mReceivers. LoaderApk is an internal class of the Android framework. It keeps the list of broadcast receivers currently registered in an ArrayMap in mReceivers

This means InboxActivity implements BroadcastReceiver, and somewhere in the code you're doing Context.registerReceiver(inboxActivity) but forgetting to do Context.unregisterReceiver(inboxActivity) when the activity is destroyed. That's what you need to fix to make the leak go away.

Upvotes: 3

Gabe Sechan
Gabe Sechan

Reputation: 93688

com.myapp.chat.InboxActivity instance ​ Leaking: YES (ObjectWatcher was watching this because com.myapp.

InboxActivity is leaking. Insufficient data to tell why it's leaking from what you posted, I would look for what references to it are outstanding.

Upvotes: 1

Related Questions