本机代码崩溃(android)?

时间:2014-06-20 07:46:13

标签: android android-ndk

我有Android应用程序,大量使用移植到Android的ffmpeg。它在大多数设备上运行良好,但在Galaxy Tab 10上崩溃:

06-20 13:16:36.136      505-561/? D/CrashAnrDetector﹕ Build: samsung/espresso10rfxx/espresso10rf:4.2.2/JDQ39/P5100XXDMJ2:user/release-keys
    Hardware: piranha
    Revision: 9
    Bootloader: unknown
    Radio: unknown
    Kernel: Linux version 3.0.31-1919150 (se.infra@SEP-107) (gcc version 4.4.1 (Sourcery G++ Lite 2010q1-202) ) #1 SMP PREEMPT Fri Oct 18 15:31:19 KST 2013
    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Build fingerprint: 'samsung/espresso10rfxx/espresso10rf:4.2.2/JDQ39/P5100XXDMJ2:user/release-keys'
    Revision: '9'
    pid: 22003, tid: 22003, name: om.company.project  >>> com.company.project <<<
    signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad
    r0 00000027  r1 deadbaad  r2 401b5258  r3 00000000
    r4 00000000  r5 bebb936c  r6 00000004  r7 40d63400
    r8 00000000  r9 409d81b0  sl 4000c0d8  fp 00000001
    ip 62675144  sp bebb9368  lr 4018854d  pc 40184be2  cpsr 60000030
    d0  65706d666662696c  d1  732e6e6f656e2d67
    d2  732e30323763692e  d3  2f322d6c6f6f6863
    d4  ff00edc0e4c09680  d5  000c000c000c000c
    d6  03fc0378033000e0  d7  3f8000003f800000
    d8  41c0000000000000  d9  000000a13f000000
    d10 0000000000000000  d11 0000000000000000
    d12 0000000000000000  d13 0000000000000000
    d14 0000000000000000  d15 0000000000000000
    d16 00ffffffffffffff  d17 004c481a004aca6e
    d18 004f4372004dc5c6  d19 00523eca0050c11e
    d20 00f5403e00ef803c  d21 0101404100fb403f
    d22 0000004400000042  d23 0000004700000045
    d24 010d404401074042  d25 0119404701134045
    d26 0000004300000041  d27 0000004600000044
    d28 00f5400000ef8000  d29 0101400000fb4000
    d30 0000000100000001  d31 0000000100000001
    scr 60000010
    backtrace:
    #00  pc 0001abe2  /system/lib/libc.so
    #01  pc 00018208  /system/lib/libc.so (abort+4)
    #02  pc 0066b8e0  /data/app-lib/com.company.project-2/libffmpeg-neon.so
    #03  pc 000032b3  /system/bin/linker
    #04  pc 0000510b  /system/bin/linker
    #05  pc 0004f973  /system/lib/libdvm.so (dvmLoadNativeCode(char const*, Object*, char**)+186)
    #06  pc 0006681d  /system/lib/libdvm.so
    #07  pc 000276e0  /system/lib/libdvm.so
    #08  pc 0002b5c4  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
    #09  pc 0005fc79  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
    #10  pc 0005fca3  /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
    #11  pc 0006ad49  /system/lib/libdvm.so (dvmInitClass+1036)
    #12  pc 000225dc  /system/lib/libdvm.so (dvmAsmSisterStart+412)
    #13  pc 0002b5c4  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
    #14  pc 0005ff4f  /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+374)
    #15  pc 00067879  /system/lib/libdvm.so
    #16  pc 000276e0  /system/lib/libdvm.so
    #17  pc 0002b5c4  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
    #18  pc 0005fc79  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
    #19  pc 00049a43  /system/lib/libdvm.so
    #20  pc 00047f43  /system/lib/libandroid_runtime.so
    #21  pc 000492df  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+390)
    #22  pc 00000db7  /system/bin/app_process
    #23  pc 0001287f  /system/lib/libc.so (__libc_init+38)
    #24  pc 00000ae8  /system/bin/app_process
    stack:
    bebb9328  f930001d
    bebb932c  5f7a1cc8
    bebb9330  4015bcf8  /system/bin/linker
    bebb9334  4015bf40  /system/bin/linker
    bebb9338  4015c4f4
    bebb933c  4015b0ac  /system/bin/linker
    bebb9340  401b2254  /system/lib/libc.so
    bebb9344  401b21b4  /system/lib/libc.so
    bebb9348  00000000
    bebb934c  4018854d  /system/lib/libc.so (_fwalk+32)
    bebb9350  00000001
    bebb9354  bebb936c  [stack]
    bebb9358  00000004
    bebb935c  40d63400  [heap]
    bebb9360  df0027ad
    bebb

由于输出中没有应用符号(JNI代码中没有我的方法),我怎么能理解错误?是否缺少.so lib应该在加载libffmpeg.so之前加载?

2 个答案:

答案 0 :(得分:1)

查看地址-DEADBAAD。用英文注意它?这意味着它是故意设置的(对它的几率是天文数字)。特别是它是JVM用来覆盖Java引用中不再有效的指针的值。因此,您将值传递给不再有效的C代码,或者C代码保留在引用上,而没有通过增加其引用计数来正确告知VM它这样做。如果你的代码是多线程的,那么这通常是竞争条件的结果。

答案 1 :(得分:1)

您可以使用Android NDK提供的ndk-stack工具。 详细信息可以从NDK doc找到: 机器人-NDK-r10d \文档\ Programmers_Guide \ HTML \ md_3__key__topics__debugging__n_d_k-_s_t_a_c_k.htm

此工具基本上可以帮助您将内存中的内容转换为人类可读的调试信息。有时,它非常有帮助。

从NDK文档中复制以下内容:

该工具可以转换以下信息

  I/DEBUG   (   31): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
  I/DEBUG   (   31): Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'
  I/DEBUG   (   31): pid: 351, tid: 351  %gt;%gt;%gt; /data/local/ndk-tests/crasher <<<
  I/DEBUG   (   31): signal 11 (SIGSEGV), fault addr 0d9f00d8
  I/DEBUG   (   31):  r0 0000af88  r1 0000a008  r2 baadf00d  r3 0d9f00d8
  I/DEBUG   (   31):  r4 00000004  r5 0000a008  r6 0000af88  r7 00013c44
  I/DEBUG   (   31):  r8 00000000  r9 00000000  10 00000000  fp 00000000
  I/DEBUG   (   31):  ip 0000959c  sp be956cc8  lr 00008403  pc 0000841e  cpsr 60000030
  I/DEBUG   (   31):          #00  pc 0000841e  /data/local/ndk-tests/crasher
  I/DEBUG   (   31):          #01  pc 000083fe  /data/local/ndk-tests/crasher
  I/DEBUG   (   31):          #02  pc 000083f6  /data/local/ndk-tests/crasher
  I/DEBUG   (   31):          #03  pc 000191ac  /system/lib/libc.so
  I/DEBUG   (   31):          #04  pc 000083ea  /data/local/ndk-tests/crasher
  I/DEBUG   (   31):          #05  pc 00008458  /data/local/ndk-tests/crasher
  I/DEBUG   (   31):          #06  pc 0000d362  /system/lib/libc.so
  I/DEBUG   (   31):

进入更易读的输出:

  ********** Crash dump: **********
  Build fingerprint: 'generic/google_sdk/generic/:2.2/FRF91/43546:eng/test-keys'
  pid: 351, tid: 351  >>> /data/local/ndk-tests/crasher <<<
  signal 11 (SIGSEGV), fault addr 0d9f00d8
  Stack frame #00  pc 0000841e  /data/local/ndk-tests/crasher : Routine zoo in /tmp/foo/crasher/jni/zoo.c:13
  Stack frame #01  pc 000083fe  /data/local/ndk-tests/crasher : Routine bar in /tmp/foo/crasher/jni/bar.c:5
  Stack frame #02  pc 000083f6  /data/local/ndk-tests/crasher : Routine my_comparison in /tmp/foo/crasher/jni/foo.c:9
  Stack frame #03  pc 000191ac  /system/lib/libc.so
  Stack frame #04  pc 000083ea  /data/local/ndk-tests/crasher : Routine foo in /tmp/foo/crasher/jni/foo.c:14
  Stack frame #05  pc 00008458  /data/local/ndk-tests/crasher : Routine main in /tmp/foo/crasher/jni/main.c:19
  Stack frame #06  pc 0000d362  /system/lib/libc.so