背景
版本发布后,收集到到异常上报,有部分记录到是native crash。 而上报的native信息,无法直接定位到错误位置。
解决方案:
一,针对可以复现到场景
1,本地debug版本进行复现,crash复现后找到debug版本的so文件(debug版本的so包含调试信息)
代码语言:javascript复制$ find . -name "libitlogin.so" | xargs ls -lhs
432 -rw-r--r-- 1 *** staff 214K Nov 15 12:16 ./app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/arm64-v8a/libitlogin.so
208 -rw-r--r-- 1 *** staff 102K Nov 15 12:16 ./app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/armeabi-v7a/libitlogin.so
408 -rw-r--r-- 1 *** staff 202K Nov 15 12:16 ./app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/x86/libitlogin.so
448 -rw-r--r-- 1 *** staff 222K Nov 15 12:16 ./app/build/intermediates/transforms/mergeJniLibs/debug/0/lib/x86_64/libitlogin.so
432 -rwxr-xr-x 1 *** staff 214K Nov 8 14:04 ./app/build/intermediates/transforms/stripDebugSymbol/debug/0/lib/arm64-v8a/libitlogin.so
208 -rwxr-xr-x 1 *** staff 102K Nov 8 14:04 ./app/build/intermediates/transforms/stripDebugSymbol/debug/0/lib/armeabi-v7a/libitlogin.so
408 -rwxr-xr-x 1 *** staff 202K Nov 8 14:04 ./app/build/intermediates/transforms/stripDebugSymbol/debug/0/lib/x86/libitlogin.so
448 -rwxr-xr-x 1 *** staff 222K Nov 8 14:04 ./app/build/intermediates/transforms/stripDebugSymbol/debug/0/lib/x86_64/libitlogin.so
5088 -rwxr-xr-x 1 *** staff 2.5M Nov 8 13:02 ./itloginlib/build/intermediates/cmake/release/obj/arm64-v8a/libitlogin.so
3384 -rwxr-xr-x 1 *** staff 1.6M Nov 8 13:02 ./itloginlib/build/intermediates/cmake/release/obj/armeabi-v7a/libitlogin.so
4232 -rwxr-xr-x 1 *** staff 2.1M Nov 8 13:02 ./itloginlib/build/intermediates/cmake/release/obj/x86/libitlogin.so
5056 -rwxr-xr-x 1 *** staff 2.5M Nov 8 13:02 ./itloginlib/build/intermediates/cmake/release/obj/x86_64/libitlogin.so
520 -rw-r--r-- 1 *** staff 258K Nov 8 13:02 ./itloginlib/build/intermediates/library_and_local_jars_jni/release/arm64-v8a/libitlogin.so
288 -rw-r--r-- 1 *** staff 142K Nov 8 13:02 ./itloginlib/build/intermediates/library_and_local_jars_jni/release/armeabi-v7a/libitlogin.so
568 -rw-r--r-- 1 *** staff 282K Nov 8 13:02 ./itloginlib/build/intermediates/library_and_local_jars_jni/release/x86/libitlogin.so
584 -rw-r--r-- 1 *** staff 290K Nov 8 13:02 ./itloginlib/build/intermediates/library_and_local_jars_jni/release/x86_64/libitlogin.so
5088 -rw-r--r-- 1 *** staff 2.5M Nov 8 13:02 ./itloginlib/build/intermediates/transforms/mergeJniLibs/release/0/lib/arm64-v8a/libitlogin.so
3384 -rw-r--r-- 1 *** staff 1.6M Nov 8 13:02 ./itloginlib/build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi-v7a/libitlogin.so
4232 -rw-r--r-- 1 *** staff 2.1M Nov 8 13:02 ./itloginlib/build/intermediates/transforms/mergeJniLibs/release/0/lib/x86/libitlogin.so
5056 -rw-r--r-- 1 *** staff 2.5M Nov 8 13:02 ./itloginlib/build/intermediates/transforms/mergeJniLibs/release/0/lib/x86_64/libitlogin.so
520 -rwxr-xr-x 1 *** staff 258K Nov 8 13:02 ./itloginlib/build/intermediates/transforms/stripDebugSymbol/release/0/lib/arm64-v8a/libitlogin.so
288 -rwxr-xr-x 1 *** staff 142K Nov 8 13:02 ./itloginlib/build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi-v7a/libitlogin.so
568 -rwxr-xr-x 1 *** staff 282K Nov 8 13:02 ./itloginlib/build/intermediates/transforms/stripDebugSymbol/release/0/lib/x86/libitlogin.so
584 -rwxr-xr-x 1 *** staff 290K Nov 8 13:02 ./itloginlib/build/intermediates/transforms/stripDebugSymbol/release/0/lib/x86_64/libitlogin.so
可以找到最大的那个so文件,这个so文件会比正常包含在apk中的so文件大N倍, 一般可以在obj/local 或者 debug/ 目录下找到。
2,根据堆栈信息,查找错误。(下面是一个实际发生的错误堆栈)
代码语言:javascript复制SIGSEGV(SEGV_MAPERR):
#00 pc 006e3136 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 33) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#01 pc 006e3132 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 29) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#02 pc 006e312e /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 25) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#03 pc 006e312a /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 21) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#04 pc 006e3126 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 17) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#05 pc 006e3122 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 13) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#06 pc 006e311e /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 9) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#07 pc 006e311a /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 5) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#08 pc 006e3116 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN16GrpcProtocolTypeI12PushProtocolN3moa11PushServiceEEC2Ev 1) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#09 pc 006e3112 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 81) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#10 pc 006e310e /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 77) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#11 pc 006e310a /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 73) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#12 pc 006e3106 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 69) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#13 pc 006e3102 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 65) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#14 pc 006e30fe /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 61) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#15 pc 006e30fa /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 57) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#16 pc 006e30f6 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 53) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#17 pc 006e30f2 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 49) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#18 pc 006e30ee /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 45) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#19 pc 006e30ea /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 41) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#20 pc 006e30e6 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 37) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#21 pc 006e30e2 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 33) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#22 pc 006e30de /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 29) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#23 pc 006e30da /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 25) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#24 pc 006e30d6 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 21) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#25 pc 006e30d2 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 17) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#26 pc 006e30ce /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 13) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#27 pc 006e30ca /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 9) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#28 pc 006e30c6 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 5) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#29 pc 006e30c2 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN12PushProtocolC1Ev 1) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#30 pc 006e30be /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN4base7android18ScopedJavaLocalRefIP8_jobjectE5ResetEP7_JNIEnvS3_ 11) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#31 pc 006e30ba /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN4base7android18ScopedJavaLocalRefIP8_jobjectE5ResetEP7_JNIEnvS3_ 7) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#32 pc 006e30b6 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN4base7android18ScopedJavaLocalRefIP8_jobjectE5ResetEP7_JNIEnvS3_ 3) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#33 pc 006e30b2 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN4base7android18ScopedJavaLocalRefIP8_jobjectE5ResetERKNS0_7JavaRefIS3_EE 7) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#34 pc 006e30ae /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN4base7android18ScopedJavaLocalRefIP8_jobjectE5ResetERKNS0_7JavaRefIS3_EE 3) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#35 pc 006e30aa /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN4base8internal9BindStateIPFvNS_7android19ScopedJavaGlobalRefIP8_jobjectEERK21GetNotificationResultEJS6_EE7DestroyEPKNS0_13BindStateBaseE 17) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#36 pc 006e30a6 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN4base8internal9BindStateIPFvNS_7android19ScopedJavaGlobalRefIP8_jobjectEERK21GetNotificationResultEJS6_EE7DestroyEPKNS0_13BindStateBaseE 13) [armeabi-v7a::51e75dab8c5e3fb807f5dc641bdfb96f]
#37 pc 006e30a2 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so (_ZN4base8internal9BindStateIPFvNS_7android19ScopedJavaGlobalRefIP8_jobjectEERK21GetNotificationResultEJS6_EE7java:
第一行堆栈信息
代码语言:javascript复制#00 pc 006e3136 /data/app/***-kELvojZn3xlCIubKv5Vtsw==/lib/arm/libmoa_content.so
#00 表示堆栈序号
pc 006e3136 表示崩溃发生时 程序计数器 位于 libmoa_content.so 偏移 006e3136 处
3,使用命令查找错误的具体位置。
代码语言:javascript复制$ arm-linux-androideabi-addr2line -C -f -e /lib/armeabi-v7a/libmoa_content.so 006e3136
arm-linux-androideabi-addr2line 路径 NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin
二,针对发版后的crash日志收集
针对发版本的apk,需要在编译阶段归档debug类的so文件。 这样在发生crash时候,才能通过归档的so文件来定位到具体的crash位置。