How to debug an Android app that crashes while the debugger is attaching?

119 views Asked by At

My app crashes while waiting for the debugger to attach in Android Studio. The debug call stack doesn't make any sense to me. How can I debug this and figure out why it's crashing?

Adding some context...

This is a video game composed of a "launch" activity that displays various game configuration options and then the "game" activity which is a NativeActivity. The launch activity is Kotlin and AndroidX Compose. So there's both SDK and NDK code.

If I just "Debug App" it will crash with a stack trace similar to the one below. The exact stack trace does seem to vary a bit because it's a timing issue, but it's similar calls.

I can't identify the thread that's crashing but it's not the Main UI thread because I can put a breakpoint on the launch activity's "create" method and it will trip, then crash after continuing.

This is the call stack of the errant thread at the time of crash on a Pixel 8 Pro.

openjdkjvmti::ThreadUtil::GetNativeThread(_jobject *, const art::ScopedObjectAccessAlreadyRunnable &, art::Thread **, jvmtiError *) 0x000000710fce06d8
openjdkjvmti::ThreadUtil::GetThreadLocalStorage(_jvmtiEnv *, _jobject *, void **) 0x000000710fce39c0
findThread 0x000000710fbdeaa0
threadControl_clearCLEInfo 0x000000710fbe0a94
event_callback 0x000000710fbd61d0
cbThreadStart 0x000000710fbd3320
openjdkjvmti::ThreadCallback::Post<…>(art::Thread *) 0x000000710fcded80
art::Thread::CreateCallback(void *) 0x0000007113f3a0d8
art::Thread::CreateCallbackWithUffdGc(void *) 0x0000007113f39b64
__pthread_start(void *) 0x00000073be361cd0
__start_thread 0x00000073be2f5b04

Here's another call stack. Sometimes this one happens instead of the above call stack.

art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2978a4
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e29790c
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e297818
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e297818
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e297818
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e297818
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e297818
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e297818
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e297818
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e29828c
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e29828c
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e2973e0
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
art::interpreter::DoCall<…>(art::ArtMethod *, art::Thread *, art::ShadowFrame &, const art::Instruction *, unsigned short, bool, art::JValue *) 0x000000795e311d20
art::interpreter::ExecuteSwitchImplCpp<…>(art::interpreter::SwitchImplContext *) 0x000000795e29828c
ExecuteSwitchImplAsm 0x000000795e157fdc
art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.420609892041422114) 0x000000795e174124
artQuickToInterpreterBridge 0x000000795e173a1c
art_quick_to_interpreter_bridge 0x000000795e15596c
art_quick_invoke_stub 0x000000795e13eda8
art::ArtMethod::Invoke(art::Thread *, unsigned int *, unsigned int, art::JValue *, const char *) 0x000000795e039d58
art::Thread::CreateCallback(void *) 0x000000795e33a1b4
art::Thread::CreateCallbackWithUffdGc(void *) 0x000000795e339b64
__pthread_start(void *) 0x00000079e8d550f8
__start_thread 0x00000079e8ceea08
0

There are 0 answers