My android app is using a native lib that occasionally crashes. Its a 3rd party library provided by a vendor from a different country so fixing the issue at the root is going to be extremely time consuming to say the least.
Is there a way to gracefully catch the exceptions in native code to prevent the entire app from shutting down?
Here's a sample stack trace, not that its really useful.
Thanks.
I/DEBUG ( 100): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 100): Build fingerprint: 'SEMC/LT15a_1247-3693/LT15a:2.3.2/3.0.A.2.181/SvfP:user/release-keys'
I/DEBUG ( 100): pid: 1427, tid: 1525 >>> com.foo.abc <<<
I/DEBUG ( 100): signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 00708f98
I/DEBUG ( 100): r0 00a179b0 r1 00010014 r2 0000000b r3 00000194
I/DEBUG ( 100): r4 40e39e50 r5 40c2c090 r6 006f64c0 r7 0000c000
I/DEBUG ( 100): r8 40c2c090 r9 006f64c0 10 0000c000 fp 00000001
I/DEBUG ( 100): ip 00708f68 sp 304e7ab0 lr 40c1d6f9 pc 00708f98 cpsr 08000010
I/DEBUG ( 100): d0 6472656767756265 d1 0d6c6d74682f7478
I/DEBUG ( 100): d2 51544d7941444e3d d3 59544e3351444f32
I/DEBUG ( 100): d4 556b4e445a6a4f77 d5 566a4e3345554e34
I/DEBUG ( 100): d6 5a454f466c7a4e46 d7 565552774d545142
I/DEBUG ( 100): d8 fff0000000000000 d9 3ff0000000000000
I/DEBUG ( 100): d10 3fc0000043f00000 d11 407e000000000000
I/DEBUG ( 100): d12 0000000000000000 d13 0000000000000000
I/DEBUG ( 100): d14 0000000000000000 d15 0000000000000000
I/DEBUG ( 100): d16 000000002c666970 d17 4040000000000000
I/DEBUG ( 100): d18 547d42aea2879f2e d19 412e848000000000
I/DEBUG ( 100): d20 4059000000000000 d21 8000000000000000
I/DEBUG ( 100): d22 0000000000000000 d23 0000000000000000
I/DEBUG ( 100): d24 0000000000000000 d25 3ff8000000000000
I/DEBUG ( 100): d26 0000000000000000 d27 3ff8000开发者_如何转开发000000000
I/DEBUG ( 100): d28 088a000008820000 d29 3ff8000000000000
I/DEBUG ( 100): d30 0000000000000000 d31 3fe5555555555555
I/DEBUG ( 100): scr 60000012
I/DEBUG ( 100):
I/DEBUG ( 100): #00 pc 00708f98 [heap]
I/DEBUG ( 100): #01 pc 0001d6f6 /data/data/com.foo.abc/lib/lib3rdpartylib.so
I/DEBUG ( 100): #02 pc 00026722 /data/data/com.foo.abc/lib/lib3rdpartylib.so
I/DEBUG ( 100): #03 pc 00074170 /data/data/com.foo.abc/lib/lib3rdpartylib.so
I/DEBUG ( 100): #04 pc 00106b58 /data/data/com.foo.abc/lib/lib3rdpartylib.so
I/DEBUG ( 100): #05 pc 0011fdd4 /data/data/com.foo.abc/lib/lib3rdpartylib.so
I/DEBUG ( 100): #06 pc 001308cc /data/data/com.foo.abc/lib/lib3rdpartylib.so
I/DEBUG ( 100): #07 pc 0002c0b8 /data/data/com.foo.abc/lib/lib3rdpartylib.so
I/DEBUG ( 100): #08 pc 000118f4 /system/lib/libc.so
I/DEBUG ( 100): #09 pc 000114c0 /system/lib/libc.so
I/DEBUG ( 100):
I/DEBUG ( 100): code around pc:
I/DEBUG ( 100): 00708f78 00000000 00000000 00a57b5c 00a57b78
I/DEBUG ( 100): 00708f88 00000020 0000004a 2f316d2f 42422f4d
I/DEBUG ( 100): 00708f98 4d2d5f56 4d5f6461 535f6e65 455f3130
I/DEBUG ( 100): 00708fa8 2d5f3130 6c70614d 4d2d5f65 32474550
I/DEBUG ( 100): 00708fb8 5f44535f 5f4d5244 4b303036 2d30302f
I/DEBUG ( 100):
I/DEBUG ( 100): code around lr:
I/DEBUG ( 100): 40c1d6d8 91029003 93009201 93049b03 681b9b04
I/DEBUG ( 100): 40c1d6e8 681a3308 98044694 9a019902 47e09b00
I/DEBUG ( 100): 40c1d6f8 bd00b007 b089b500 91029003 93009201
I/DEBUG ( 100): 40c1d708 93062300 93059b03 681b9b05 681a330c
I/DEBUG ( 100): 40c1d718 98054694 9a019902 47e09b00 93061c03
I/DEBUG ( 100):
I/DEBUG ( 100): stack:
I/DEBUG ( 100): 304e7a70 00010014 [heap]
I/DEBUG ( 100): 304e7a74 0000000b
I/DEBUG ( 100): 304e7a78 00000194
Write a java signal handler - like the one here - to catch SIGILL/-4 (as that is what your library is throwing).
Have the signal handler throw an exception, this will beautify things somewhat.
精彩评论