1、使用Android Studio调试APP代码时,出现如下错误,很明显是C代码报错了:
A/DEBUG: Build fingerprint: 'Xiaomi/cancro_lte_ct/cancro:6.0.1/MMB29M/6.8.4:user/release-keys'
A/DEBUG: Revision: '0'
A/DEBUG: ABI: 'arm'
A/DEBUG: pid: 29614, tid: 29712, name: shihujiaoserver >>> ruijie.hushihujiaoserver <<<
A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
A/DEBUG: Abort message: 'Invalid address 0x9a2e3928 passed to free: value not allocated'
A/DEBUG: r0 00000000 r1 00007410 r2 00000006 r3 9a2e3978
A/DEBUG: r4 9a2e3980 r5 9a2e3930 r6 00000002 r7 0000010c
A/DEBUG: r8 9fe7f688 r9 b6ca1594 sl 00000001 fp 9a407b55
A/DEBUG: ip 00000006 sp 9a2e31d0 lr b6c6ac51 pc b6c6d040 cpsr 400f0010
A/DEBUG: backtrace:
A/DEBUG: #00 pc 00042040 /system/lib/libc.so (tgkill+12)
A/DEBUG: #01 pc 0003fc4d /system/lib/libc.so (pthread_kill+32)
A/DEBUG: #02 pc 0001c3fb /system/lib/libc.so (raise+10)
A/DEBUG: #03 pc 000195ad /system/lib/libc.so (__libc_android_abort+34)
A/DEBUG: #04 pc 00017500 /system/lib/libc.so (abort+4)
A/DEBUG: #05 pc 0001b00f /system/lib/libc.so (__libc_fatal+16)
A/DEBUG: #06 pc 00055463 /system/lib/libc.so (ifree+202)
A/DEBUG: #07 pc 00058347 /system/lib/libc.so (je_free+374)
A/DEBUG: #08 pc 00099d2f /data/app/ruijie.hushihujiaoserver-1/lib/arm/libserver-jni.so
A/DEBUG: #09 pc 000284db /data/app/ruijie.hushihujiaoserver-1/lib/arm/libserver-jni.so (sqlite3_free+86)
A/DEBUG: #10 pc 00015f0d /data/app/ruijie.hushihujiaoserver-1/lib/arm/libserver-jni.so
A/DEBUG: #11 pc 0001669b /data/app/ruijie.hushihujiaoserver-1/lib/arm/libserver-jni.so (db_init_sysconfig_head+62)
A/DEBUG: #12 pc 000148db /data/app/ruijie.hushihujiaoserver-1/lib/arm/libserver-jni.so (sysconfig_init+10)
A/DEBUG: #13 pc 00024ebf /data/app/ruijie.hushihujiaoserver-1/lib/arm/libserver-jni.so (server_task+874)
A/DEBUG: #14 pc 0003f54f /system/lib/libc.so (_ZL15__pthread_startPv+30)
A/DEBUG: #15 pc 00019c2f /system/lib/libc.so (__start_thread+6)
A/DEBUG: Tombstone written to: /data/tombstones/tombstone_08
E/DEBUG: AM write failed: Broken pipe
E/octvm_klo: read: Unexpected EOF!
2、如何定位呢?可以使用SDK目录中的arm-linux-androideabi-addr2line工具,我本地的目录如下:
**\androidsdk\ndk-bundle\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-addr2line.exe
使用方法:
第一步:cmd到报错的动态库目录下,位置在obj目录下,并非libs目录下生成的so文件,我的目录是**(项目目录)\jnilib\src\main\obj\local\armeabi\**
第二步:使用如下命令定位错误:**\androidsdk\ndk-bundle\toolchains\arm-linux-androideabi-4.9\prebuilt\windows-x86_64\bin\arm-linux-androideabi-addr2line -C -f -e libxxx.so 0x#####(address)
参考:如何使用arm-linux-androideabi-addr2line