Search code examples
androidcandroid-ndkffmpegjava-native-interface

Process terminates by signal calling ffmpeg part in Android NDK project


According to this blog post I've build my Android ffmpeg project. I've written the native code from my Java code with the static library and the jni functions. When I run this part of code I obtain the next logcat, any idea of why my process terminates by signal?

03-14 11:16:06.488: I/DEBUG(31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
03-14 11:16:06.488: I/DEBUG(31): Build fingerprint: generic/google_sdk/generic:2.3.4/GINGERBREAD/123630:eng/test-keys'
03-14 11:16:06.488: I/DEBUG(31): pid: 377, tid: 377  >>> com.testffmpeg <<<
03-14 11:16:06.488: I/DEBUG(31): signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 80a98f10
03-14 11:16:06.488: I/DEBUG(31):  r0 002b0030  r1 80b1c410  r2 00030d40  r3 00000000
03-14 11:16:06.488: I/DEBUG(31):  r4 00000000  r5 002b0030  r6 00000010  r7 00000010
03-14 11:16:06.488: I/DEBUG(31):  r8 be877308  r9 7fffffff  10 80b1bea0  fp 00000000
03-14 11:16:06.488: I/DEBUG(31):  ip be8772f0  sp be8772d0  lr 80a99d64  pc 80a98f10  cpsr 60000010
03-14 11:16:06.568: I/DEBUG(31):          #00  pc 00298f10  /data/data/com.testffmpeg/lib/libffmpeg.so
03-14 11:16:06.568: I/DEBUG(31):          #01  lr 80a99d64  /data/data/com.testffmpeg/lib/libffmpeg.so
03-14 11:16:06.568: I/DEBUG(31): code around pc:
03-14 11:16:06.568: I/DEBUG(31): 80a98ef0 eaffff9e 0009304c fffeffe4 e92d4010 
03-14 11:16:06.568: I/DEBUG(31): 80a98f00 e24dd020 e28dc020 e3a04000 e1cd20f8 
03-14 11:16:06.568: I/DEBUG(31): 80a98f10 e3003000 e52c4004 e3a02000 e3433ff0 
03-14 11:16:06.568: I/DEBUG(31): 80a98f20 e58dc010 e3a0c001 e58dc000 ebffff77 
03-14 11:16:06.568: I/DEBUG(31): 80a98f30 e1500004 b1a00004 a59d001c e28dd020 
03-14 11:16:06.568: I/DEBUG(31): code around lr:
03-14 11:16:06.568: I/DEBUG(31): 80a99d44 ed947b04 e1a00005 e5941000 eefd7bc7 
03-14 11:16:06.568: I/DEBUG(31): 80a99d54 ee17ca90 e1a0200c e1a03fc2 ebfffc65 
03-14 11:16:06.568: I/DEBUG(31): 80a99d64 eaffffb8 e1c421d0 e1a00008 e58d9000 
03-14 11:16:06.568: I/DEBUG(31): 80a99d74 eb0008cc e1a00005 e5941000 e898000c 
03-14 11:16:06.568: I/DEBUG(31): 80a99d84 ebfffc6e eaffffaf e1a00005 e3a01030 
03-14 11:16:06.568: I/DEBUG(31): stack:
03-14 11:16:06.568: I/DEBUG(31):     be877290  001f9a98  [heap]
03-14 11:16:06.568: I/DEBUG(31):     be877294  0008ced8  [heap]
03-14 11:16:06.568: I/DEBUG(31):     be877298  00000005  
03-14 11:16:06.578: I/DEBUG(31):     be87729c  a8114ca9  /system/lib/libutils.so
03-14 11:16:06.578: I/DEBUG(31):     be8772a0  001f9a48  [heap]
03-14 11:16:06.578: I/DEBUG(31):     be8772a4  be8772cc  
03-14 11:16:06.578: I/DEBUG(31):     be8772a8  fffffffc  
03-14 11:16:06.578: I/DEBUG(31):     be8772ac  00000000  
03-14 11:16:06.578: I/DEBUG(31):     be8772b0  be8772cc  
03-14 11:16:06.578: I/DEBUG(31):     be8772b4  a821a33d  /system/lib/libbinder.so
03-14 11:16:06.578: I/DEBUG(31):     be8772b8  00271270  [heap]
03-14 11:16:06.578: I/DEBUG(31):     be8772bc  a821a9d5  /system/lib/libbinder.so
03-14 11:16:06.578: I/DEBUG(31):     be8772c0  00000030  
03-14 11:16:06.578: I/DEBUG(31):     be8772c4  00000000  
03-14 11:16:06.578: I/DEBUG(31):     be8772c8  df002777  
03-14 11:16:06.578: I/DEBUG(31):     be8772cc  e3a070ad  
03-14 11:16:06.578: I/DEBUG(31): #00 be8772d0  00000000  
03-14 11:16:06.578: I/DEBUG(31):     be8772d4  afd10f08  /system/lib/libc.so
03-14 11:16:06.578: I/DEBUG(31):     be8772d8  00030d40  [heap]
03-14 11:16:06.578: I/DEBUG(31):     be8772dc  00000000  
03-14 11:16:06.578: I/DEBUG(31):     be8772e0  000000da  
03-14 11:16:06.578: I/DEBUG(31):     be8772e4  00000008  
03-14 11:16:06.578: I/DEBUG(31):     be8772e8  000001b4  
03-14 11:16:06.578: I/DEBUG(31):     be8772ec  c0000000  
03-14 11:16:06.578: I/DEBUG(31):     be8772f0  80b24938  /data/data/com.testffmpeg/lib/libffmpeg.so
03-14 11:16:06.578: I/DEBUG(31):     be8772f4  80a99d64  /data/data/com.testffmpeg/lib/libffmpeg.so
03-14 11:16:06.578: I/DEBUG(31):     be8772f8  00000000  
03-14 11:16:06.578: I/DEBUG(31):     be8772fc  afd1386d  /system/lib/libc.so
03-14 11:16:06.578: I/DEBUG(31):     be877300  00000000  
03-14 11:16:06.578: I/DEBUG(31):     be877304  80b1be7c  /data/data/com.testffmpeg/lib/libffmpeg.so
03-14 11:16:06.578: I/DEBUG(31):     be877308  002b0028  [heap]
03-14 11:16:06.578: I/DEBUG(31):     be87730c  00000000  
03-14 11:16:06.578: I/DEBUG(31):     be877310  00000003  
03-14 11:16:06.578: I/DEBUG(31):     be877314  00000000  
03-14 11:16:07.118: D/Zygote(33): Process 377 terminated by signal (4)

Solution

  • I would say you should check if the compiler flags you are giving to the android ndk toolchain when compiling your libs are compatible with the device you are testing in.

    Basically you are receiving a SIGILL signal, it means you are executing an illegal instruction, see here.

    The pc (program counter register) is pointing to the address 80a98f10. In the memory dump that address has the next data e3003000. I would say that is the instruction is giving you problems (I don't know which is the instruction as I don't know how to decode hex ARM instructions).

    If you want more clues you can use Google's ndk objdump (see /your-ndk-folder/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-objdump). That program can disassemble your library if you execute:

    arm-eabi-objdump -D yourLib.so
    

    Get the output and look for the string e300. Then you will see which is the instruction and knowing it might give you an idea of what is going on.

    I hope that helps.