26.so库崩溃问题 Fatal signal xx (SIGSEGV) at xxxxxx 错误定位代码的解决方法

so库崩溃问题,例如
--libstagefright.so库崩溃:

F/libc    ( 2566): Fatal signal 11 (SIGSEGV) at 0x40123d5c (code=2), thread 4550 (AmplayerMain)
I/DEBUG   ( 2562): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG   ( 2562): Build fingerprint: 'MBX/g18ref/g18ref:4.2.2/JDQ39/20130604:userdebug/test-keys'
I/DEBUG   ( 2562): Revision: '32'
I/DEBUG   ( 2562): pid: 2566, tid: 4550, name: playerMain  >>> /system/bin/mediaserver <<<
I/DEBUG   ( 2562): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 40123d5c
I/DEBUG   ( 2562):     r0 40197338  r1 455ccac4  r2 4410d008  r3 401f7cbb
I/DEBUG   ( 2562):     r4 40197268  r5 40123d5c  r6 401972fc  r7 4421e8e0
I/DEBUG   ( 2562):     r8 40197284  r9 00000000  sl 455ccca4  fp 40ec0bb0
I/DEBUG   ( 2562):     ip 00000001  sp 455ccac0  lr 406a08dd  pc 40123d5c  cpsr 60070010
I/DEBUG   ( 2562):     d0  007265706f6f4c20  d1  796461657279616c
I/DEBUG   ( 2562):     d2  747463657269642e  d3  2f74656e2e737061
I/DEBUG   ( 2562):     d4  747368746f6f6d73  d5  2f676e696d616572
I/DEBUG   ( 2562):     d6  3032375353575353  d7  532f525034363248
I/DEBUG   ( 2562):     d8  000000003f4ccccd  d9  0000000000000000
I/DEBUG   ( 2562):     d10 0000000000000000  d11 0000000000000000
I/DEBUG   ( 2562):     d12 0000000000000000  d13 0000000000000000
I/DEBUG   ( 2562):     d14 0000000000000000  d15 0000000000000000
I/DEBUG   ( 2562):     d16 0000000000000000  d17 4024000000000000
I/DEBUG   ( 2562):     d18 3fdfffffffff7360  d19 3fe0000000000000
I/DEBUG   ( 2562):     d20 3fe0000000004650  d21 3e66376972bea4d0
I/DEBUG   ( 2562):     d22 3fd1cb8765719d59  d23 bfbcb8765719d592
I/DEBUG   ( 2562):     d24 3ff1cb8765719d59  d25 0000000000000000
I/DEBUG   ( 2562):     d26 0000000000000000  d27 0000000000000000
I/DEBUG   ( 2562):     d28 0000000000000000  d29 0000000000000000
I/DEBUG   ( 2562):     d30 0000000000000000  d31 0000000000000000
I/DEBUG   ( 2562):     scr 20000010
I/DEBUG   ( 2562): 
I/DEBUG   ( 2562): backtrace:
I/DEBUG   ( 2562):     #00  pc 00000d5c  
I/DEBUG   ( 2562):     #01  pc 0009f8db  /system/lib/libstagefright.so (android::SmoothStreamingExtractor::SmoothStreamingExtractor(android::sp const&)+366)
I/DEBUG   ( 2562):     #02  pc 00082f89  /system/lib/libstagefright.so (android::MediaExtractor::Create(android::sp const&, char const*)+500)
I/DEBUG   ( 2562):     #03  pc 00045cdf  /system/lib/libmediaplayerservice.so (android::AmlogicPlayerExtractorDemux::AmlogicPlayerExtractorDemux(AVFormatContext*)+438)
I/DEBUG   ( 2562):     #04  pc 0004602d  /system/lib/libmediaplayerservice.so 

--libopenssl_static.so库崩溃:

[14:25:50]I/DEBUG   ( 1531): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
[14:25:50]I/DEBUG   ( 1531): Build fingerprint: 'HiDPT/StarTV_Hi551/Hi3751V551:5.1.1/LMY49J/T2.1.1.03:user/release-keys'
[14:25:50]I/DEBUG   ( 1531): Revision: '0'
[14:25:50]I/DEBUG   ( 1531): ABI: 'arm'
[14:25:50]I/DEBUG   ( 1531): pid: 7384, tid: 7474, name: SodpSocketThrea  >>> com.startimes.startv <<<
[14:25:50]I/DEBUG   ( 1531): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x20
[14:25:50]I/DEBUG   ( 1531):     r0 00000000  r1 f4bd8000  r2 00001000  r3 00000000
[14:25:50]E/DEBUG   ( 1531): AM write failure (32 / Broken pipe)
[14:25:50]I/DEBUG   ( 1531):     r4 f4b329c0  r5 e1ad1a88  r6 00000000  r7 f4bd8000
[14:25:50]I/DEBUG   ( 1531):     r8 00001000  r9 e1ad1a8c  sl 00001000  fp 00000003
[14:25:50]I/DEBUG   ( 1531):     ip e1ad1990  sp e1ad1a60  lr e201bda1  pc e20285dc  cpsr 60010010
[14:25:50]I/DEBUG   ( 1531): 
[14:25:50]I/DEBUG   ( 1531): backtrace:
[14:25:50]I/DEBUG   ( 1531):     #00 pc 000475dc  /system/lib/libopenssl_static.so (SSL_read)

logcat方式打印出来的这些看似淫乱的错误日志其实就是错误堆栈的相关信息,错误日志中backtracer堆栈信息,#00 #01 #02 ... 就是堆栈列表。 #00 就是堆栈顶层就是错误所在地址,pc后面的就是地址00000d5c就是crash时代码的位置。
1、工具一:arm-eabi-addr2line

startimes@ubuntu:~/disk6/MStar6A638$ ./prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/bin/arm-eabi-addr2line  -f 
-e out/target/product/arbutus/symbols/system/lib/libopenssl_static.so 000475dc

使用方法很简单:
// -f        输出函数名
// -e        输出错误代码行数和文件路径
// xxx.so    对应出错的so文件, 在android工程obj目录下
// addr      是具体的地址
.../arm-eabi-addr2line -f -e xxx.so 000xx
ndk对应的工具路径:
android-ndk-r10\toolchains\arm-linux-androideabi-4.8\prebuilt\windows-x86_64\bin\arm-linux-androideabi-addr2line

注意:
这个so文件是android工程obj目录里面的,而不是libs里面的。
obj目录是带有debug信息的库文件,libs的库文件是没有debug信息的,addr2line无法读取源代码信息。

在源码编译的根目录下,执行:

addr2line -e out/target/product/g18ref/symbols/system/lib/libstagefright.so 0009f8db

或者执行:

arm-eabi-addr2line -f -e out/target/product/g18ref/symbols/system/lib/libstagefright.so 0009f8db

可以直接得到出错问题的具体行数

2、工具二:arm-eabi-objdump

startimes@ubuntu:~/disk6/MStar6A638$ ./prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/bin/arm-eabi-objdump -S libopenssl_static.so > openssl_map.txt

成功生成openssl_map.txt之后,打开该文件找到地址 475dc,就是问题出现的位置:

000475d0 :
   475d0:   e92d4008    push    {r3, lr}
   475d4:   e5903008    ldr r3, [r0, #8]
   475d8:   e5933060    ldr r3, [r3, #96]   ; 0x60
   475dc:   e12fff33    blx r3
   475e0:   e8bd8008    pop {r3, pc}

000475e4 :
   475e4:   e590c020    ldr ip, [r0, #32]
   475e8:   e1a03000    mov r3, r0

该问题是跳转指令 blx处空指针问题引起的崩溃,判断处理之后正常。

你可能感兴趣的:(26.so库崩溃问题 Fatal signal xx (SIGSEGV) at xxxxxx 错误定位代码的解决方法)