Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 4358 (CameraPreviewTh)问题解决

前些天在调试Camera模块;发现相同的代码在厂家提供的环境里边编译、就是ok的,在我们的源码树中编译,将HAL库推进去后、就会signal 11退出。

一、现象

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
F/libc ( 4250): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 4358 (CameraPreviewTh)
I/DEBUG ( 2366): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 2366): Build fingerprint: 'TV/tclm6/tclm6:4.2.1/V8-AML7601-LF1R001/20130523:eng/test-keys'
I/DEBUG ( 2366): Revision: '32'
I/DEBUG ( 2366): pid: 4250, tid: 4358, name: CameraPreviewTh >>> /system/bin/mediaserver <<<
I/DEBUG ( 2366): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
I/DEBUG ( 2366): r0 00000000 r1 00000500 r2 45498500 r3 0000001e
I/DEBUG ( 2366): r4 00000280 r5 00000000 r6 00000780 r7 00000000
I/DEBUG ( 2366): r8 00000500 r9 00000780 sl 00000f00 fp 45498f00
I/DEBUG ( 2366): ip 00000280 sp 46054d80 lr 4410816f pc 44108214 cpsr 80030030
I/DEBUG ( 2366): d0 696765623e3e3e31 d1 3e3e3e2d2d2d2d2d
I/DEBUG ( 2366): d2 3234767975793e3e d3 32766e5f6f745f32
I/DEBUG ( 2366): d4 54535f5745495645 d5 4552503e2d455441
I/DEBUG ( 2366): d6 4154535f57454956 d7 0000823549742400
I/DEBUG ( 2366): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 2366): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 2366): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 2366): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 2366): d16 0000000000000000 d17 0000000000000000
I/DEBUG ( 2366): d18 4000000000000000 d19 bf66c168e3a87def
I/DEBUG ( 2366): d20 3fc555533bceb625 d21 3e66376972bea4d0
I/DEBUG ( 2366): d22 3fb0271122ac41c2 d23 bf8388915620e116
I/DEBUG ( 2366): d24 3ff0271122ac41c2 d25 0000000000000000
I/DEBUG ( 2366): d26 0000000000000000 d27 0000000000000000
I/DEBUG ( 2366): d28 0000000000000000 d29 0000000000000000
I/DEBUG ( 2366): d30 0000000000000000 d31 0000000000000000
I/DEBUG ( 2366): scr 60000010
I/DEBUG ( 2366):
I/DEBUG ( 2366): backtrace:
I/DEBUG ( 2366): #00 pc 0002e214 /system/lib/hw/camera.meson6.so (yuyv422_to_nv21(unsigned char*, unsigned char*, int, int)+195)
I/DEBUG ( 2366): #01 pc 0002d05b /system/lib/hw/camera.meson6.so (android::V4LCameraAdapter::previewThread()+490)
I/DEBUG ( 2366): #02 pc 0002d145 /system/lib/hw/camera.meson6.so
I/DEBUG ( 2366): #03 pc 00011253 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+94)
I/DEBUG ( 2366): #04 pc 00010dcd /system/lib/libutils.so
I/DEBUG ( 2366): #05 pc 0000e478 /system/lib/libc.so (__thread_entry+72)
I/DEBUG ( 2366): #06 pc 0000db64 /system/lib/libc.so (pthread_create+160)
I/DEBUG ( 2366):
I/DEBUG ( 2366): stack:
I/DEBUG ( 2366): 46054d40 401da160 /system/lib/libc.so
I/DEBUG ( 2366): 46054d44 401b3a6d /system/lib/libc.so (vfprintf+44)
I/DEBUG ( 2366): 46054d48 000001e0
I/DEBUG ( 2366): 46054d4c 00000280
I/DEBUG ( 2366): 46054d50 4411bce1 /system/lib/hw/camera.meson6.so
I/DEBUG ( 2366): 46054d54 45498500 /dev/video0
I/DEBUG ( 2366): 46054d58 00000003
I/DEBUG ( 2366): 46054d5c 401b167d /system/lib/libc.so (printf+24)
I/DEBUG ( 2366): 46054d60 4411d5fa /system/lib/hw/camera.meson6.so
I/DEBUG ( 2366): 46054d64 46054d74
I/DEBUG ( 2366): 46054d68 00000280
I/DEBUG ( 2366): 46054d6c 4410816f /system/lib/hw/camera.meson6.so (yuyv422_to_nv21(unsigned char*, unsigned char*, int, int)+30)
I/DEBUG ( 2366): 46054d70 4411d5fa /system/lib/hw/camera.meson6.so
I/DEBUG ( 2366): 46054d74 00000000
I/DEBUG ( 2366): 46054d78 df0027ad
I/DEBUG ( 2366): 46054d7c 00000000
I/DEBUG ( 2366): #00 46054d80 00000280
I/DEBUG ( 2366): 46054d84 45498000 /dev/video0
I/DEBUG ( 2366): 46054d88 45498500 /dev/video0
I/DEBUG ( 2366): 46054d8c 45498a00 /dev/video0
I/DEBUG ( 2366): 46054d90 00000780
I/DEBUG ( 2366): 46054d94 0004b000
I/DEBUG ( 2366): 46054d98 0004b280
I/DEBUG ( 2366): 46054d9c 0004b001
I/DEBUG ( 2366): 46054da0 0004b281
I/DEBUG ( 2366): 46054da4 45498000 /dev/video0
I/DEBUG ( 2366): 46054da8 45498500 /dev/video0
I/DEBUG ( 2366): 46054dac 45498a00 /dev/video0
I/DEBUG ( 2366): 46054db0 45498f00 /dev/video0
I/DEBUG ( 2366): 46054db4 45498001 /dev/video0
I/DEBUG ( 2366): 46054db8 45498a01 /dev/video0
I/DEBUG ( 2366): 46054dbc 45498003 /dev/video0
I/DEBUG ( 2366): ........ ........
I/DEBUG ( 2366): #01 46054e08 00000000
I/DEBUG ( 2366): 46054e0c 00000000
I/DEBUG ( 2366): 46054e10 00000000
I/DEBUG ( 2366): 46054e14 00000000
I/DEBUG ( 2366): 46054e18 00000000
I/DEBUG ( 2366): 46054e1c 00000000
I/DEBUG ( 2366): 46054e20 00000000
I/DEBUG ( 2366): 46054e24 00000000
I/DEBUG ( 2366): 46054e28 00000280
I/DEBUG ( 2366): 46054e2c 000001e0
I/DEBUG ( 2366): 46054e30 00000000
I/DEBUG ( 2366): 46054e34 00000000
I/DEBUG ( 2366): 46054e38 00000000
I/DEBUG ( 2366): 46054e3c 00000000
I/DEBUG ( 2366): 46054e40 00000000
I/DEBUG ( 2366): 46054e44 00000000
I/DEBUG ( 2366): ........ ........
I/DEBUG ( 2366): #02 46054e98 44001498
I/DEBUG ( 2366): 46054e9c 40226255 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+96)
I/DEBUG ( 2366):
I/DEBUG ( 2366): memory near r2:
I/DEBUG ( 2366): 454984e0 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 454984f0 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498500 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498510 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498520 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498530 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498540 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498550 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498560 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498570 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498580 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498590 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 454985a0 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 454985b0 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 454985c0 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 454985d0 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366):
I/DEBUG ( 2366): memory near fp:
I/DEBUG ( 2366): 45498ee0 ffffffff ffffffff ffffffff ffffffffI/DEBUG ( 2366): 45498ef0 ffffffff ffffffff ffffffff ffffffff
I/DEBUG ( 2366): 45498f00 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f10 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f20 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f30 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f40 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f50 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f60 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f70 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f80 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498f90 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498fa0 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498fb0 ffffffff ffffffff ffffffff ffffffff I/DEBUG ( 2366): 45498fc0 ffffffff ffffffff ffffffff..
二、解决

1.分析其中的重要信息

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
I/DEBUG ( 2366): #00 pc 0002e180 /system/lib/hw/camera.meson6.so (yuyv422_to_nv21(unsigned char*, unsigned char*, int, int)+157)
I/DEBUG ( 2366): #01 pc 0002d00b /system/lib/hw/camera.meson6.so (android::V4LCameraAdapter::previewThread()+458)
I/DEBUG ( 2366): #02 pc 0002d0dd /system/lib/hw/camera.meson6.so
I/DEBUG ( 2366): #03 pc 00011253 /system/lib/libutils.so (android::Thread::_threadLoop(void*)+94)
I/DEBUG ( 2366): #04 pc 00010dcd /system/lib/libutils.so
I/DEBUG ( 2366): #05 pc 0000e478 /system/lib/libc.so (__thread_entry+72)
I/DEBUG ( 2366): #06 pc 0000db64 /system/lib/libc.so (pthread_create+160)
2.代码跟踪

操作:
out/target/product/tclm6/obj/SHARED_LIBRARIES/camera.meson6_intermediates/LINKED
arm-none-linux-gnueabi-addr2line 0002e180 -e camera.meson6.so
结果:
hardware/amlogic/camera/utils/util.cpp:157
////(*ptrdesty1++) = (*ptrsrcy1);在yuyv422_to_nv21(unsigned char*, unsigned char*, int, int)函数中

操作:
arm-none-linux-gnueabi-addr2line 0002d00b -e camera.meson6.so
结果:
hardware/amlogic/camera/V4LCameraAdapter/V4LCameraAdapter.cpp:1571
//// yuyv422_to_nv21(src,dest,width,height);

操作:
arm-none-linux-gnueabi-addr2line 0002d0dd -e camera.meson6.so
结果:
hardware/amlogic/camera/V4LCameraAdapter/V4LCameraAdapter.cpp:303
////writefile((char*)SYSFILE_CAMERA_SET_PARA, (char*)"1");
3.分析

从上边结果来看,在hardware/amlogic/camera/V4LCameraAdapter/V4LCameraAdapter.cpp:1571处调用yuyv422_to_nv21(src,dest,width,height)挂掉的可能性比较打;于是加如下log:

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
D/V4LCameraAdapter( 2371): TK----------->>>>>src is 0x45d0f000
D/V4LCameraAdapter( 2371): TK---------->>>>>>dest is 0x0
D/V4LCameraAdapter( 2371): TK------------>>>>>width is 640
D/V4LCameraAdapter( 2371): TK--------->>>>>height is 480
不难发现,上边dest指针为NULL、导致的signal 11。

4.解决

通过对比编译环境发现,在dest赋值处;用到的头文件位置不同,导致结果差异。通过重新设置头文件路径,问题解决。

三、思考

目前掌握的结局signal 11故障的方法是使用交叉编译工具链给我们提供的arm-none-linux-gnueabi-addr2line工具,通过地址定位源文件中出错的函数或具体行数。

四、补充:Fatal signal 8 (SIGFPE)

最近在帮助同事看一个打印堆栈问题时发现,程序并没有被kill掉

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
F/libc ( 3254): Fatal signal 8 (SIGFPE) at 0x00000cb6 (code=0), thread 3254 (TVMSFserver)
I/DEBUG ( 2455): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 2455): Build fingerprint: 'TV/tclm6/tclm6:4.2.2/V8-AML7602-LF1V002/20140520:eng/test-keys'
I/DEBUG ( 2455): Revision: '32'
I/DEBUG ( 2455): pid: 3254, tid: 3254, name: TVMSFserver >>> TVMSFserver <<<
I/DEBUG ( 2455): signal 8 (SIGFPE), code -6 (?), fault addr 00000cb6
D/atv_hd ( 2439): ATVTunerSetStd, tuner std = 0x40000e0(V4L2_COLOR_STD_PAL, V4L2_STD_PAL_DK).
I/DEBUG ( 2455): r0 00000000 r1 00000008 r2 0000270f r3 00000000
I/DEBUG ( 2455): r4 00000000 r5 ffffffff r6 00000000 r7 00000025
I/DEBUG ( 2455): r8 00000001 r9 00000000 sl 4012e228 fp bed8ca2c
I/DEBUG ( 2455): ip fffdc390 sp bed8c660 lr 4011e010 pc 400fc27c cpsr 200a0010
I/DEBUG ( 2455): d0 6168772d2d2d2d2d d1 5654582d2d2d2d2d
I/DEBUG ( 2455): d2 6b6361626c6c6163 d3 2d2d2d2d7070632e
I/DEBUG ( 2455): d4 6c6c61635654582d d5 45533a3a6b636162
I/DEBUG ( 2455): d6 4c41435f48435241 d7 2d2d2d4b4341424c
I/DEBUG ( 2455): d8 0000000000000000 d9 0000000000000000
I/DEBUG ( 2455): d10 0000000000000000 d11 0000000000000000
I/DEBUG ( 2455): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 2455): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 2455): d16 41d4e400c2003127 d17 3f50624dd2f1a9fc
I/DEBUG ( 2455): d18 41cc382ea1800000 d19 0000000000000000
I/DEBUG ( 2455): d20 0000000000000000 d21 0000000000000000
I/DEBUG ( 2455): d22 0000000000000000 d23 0000000000000000
I/DEBUG ( 2455): d24 0000000000000000 d25 0000000000000000
I/DEBUG ( 2455): d26 0000000000000000 d27 0000000000000000
I/DEBUG ( 2455): d28 0000000000000000 d29 0000000000000000
I/DEBUG ( 2455): d30 0000000000000000 d31 0000000000000000
I/DEBUG ( 2455): scr 00000010
I/DEBUG ( 2455):
I/DEBUG ( 2455): backtrace:
I/DEBUG ( 2455): #00 pc 0001827c /system/lib/libc.so (kill+12)
I/DEBUG ( 2455): #01 pc 0003a00c /system/lib/libc.so (__aeabi_idiv0+8)
I/DEBUG ( 2455):
I/DEBUG ( 2455): stack:
I/DEBUG ( 2455): bed8c620 00000008
I/DEBUG ( 2455): bed8c624 00000000
I/DEBUG ( 2455): bed8c628 00000000
I/DEBUG ( 2455): bed8c62c 00000000
I/DEBUG ( 2455): bed8c630 00000000
I/DEBUG ( 2455): bed8c634 41010001 /system/lib/libamplayer.so (ff_ps_init+1361)
I/DEBUG ( 2455): bed8c638 00000000
I/DEBUG ( 2455): bed8c63c 00000030
I/DEBUG ( 2455): bed8c640 ffffffe0
I/DEBUG ( 2455): bed8c644 00000000
I/DEBUG ( 2455): bed8c648 00000000
I/DEBUG ( 2455): bed8c64c 00000000
I/DEBUG ( 2455): bed8c650 00000000
I/DEBUG ( 2455): bed8c654 00000000
I/DEBUG ( 2455): bed8c658 df0027ad
I/DEBUG ( 2455): bed8c65c 00000000
I/DEBUG ( 2455): #00 bed8c660 00000000
I/DEBUG ( 2455): ........ ........
I/DEBUG ( 2455): #01 bed8c660 00000000
I/DEBUG ( 2455): bed8c664 ffffffff
I/DEBUG ( 2455): bed8c668 00000000
I/DEBUG ( 2455): bed8c66c bed8c6a0 [stack]
I/DEBUG ( 2455): bed8c670 fffdc390
I/DEBUG ( 2455): bed8c674 4011e010 /system/lib/libc.so (__aeabi_idiv0+12)
I/DEBUG ( 2455): bed8c678 00000000
I/DEBUG ( 2455): bed8c67c 4038223d /data/test/libTVMSFService.so (android::postEventsFromhal(int, android::Parcel const*)+236)
I/DEBUG ( 2455): bed8c680 00000002
I/DEBUG ( 2455): bed8c684 00000002
I/DEBUG ( 2455): bed8c688 41bd2c28
I/DEBUG ( 2455): bed8c68c 00000063
I/DEBUG ( 2455): bed8c690 000c2e2a
I/DEBUG ( 2455): bed8c694 00000003
I/DEBUG ( 2455): bed8c698 00000004
I/DEBUG ( 2455): bed8c69c 418fbb01 /data/test/libdtvapi_dtv.so (std::basic_stringbuf, std::allocator >::xsputn(char const*, int)+8)
通过地址定位:
arm-none-linux-gnueabi-addr2line 0001827c -e libc.so
结果:

bionic/libc/arch-arm/bionic/kill.S:46

[plain] view plaincopy在CODE上查看代码片派生到我的代码片
ENTRY(kill)
stmfd sp!, {r4-r7, ip, lr}
ldr r7, =__NR_kill
swi #0
ldmfd sp!, {r4-r7, ip, lr} //46行,恢复现场
movs r0, r0
bxpl lr
b __set_syscall_errno
END(kill)
后发现signal 8问题一般是由于除数为0导致,后问题解决;通过该问题分析:可能是因为signal 8后系统需要kill该进程、但没有kill成功。

 

这篇文章不错,不过还是和我的有点不一样,

看看老外是怎么解决的

You can try to analyze memory for your Android application:
http://developer.android.com/tools/help/traceview.html
http://android-developers.blogspot.se/2011/03/memory-analysis-for-android.html

 

你可能感兴趣的:(android)