javaandroidandroid-ndkdalvikaddr2line

How to get Crash Point in Java code


My application has android-support-v4.jar in /libs only. I do not use other library.

My application is crashing with SIGNAL 11 error. I want to use addr2line utility of android-ndk. Can we find the function and line number of java file using this tool? Any help will be very helpful here

My application is writing to Bluetooth Socket and in between i am closing the socket I suspect, the error is coming because write() is called after close() of socket But I am not able to find exact line or function of crash How can i check where i am doing wrong

Logcat trace :

D/CrashAnrDetector(831): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000008
D/CrashAnrDetector(831):     r0 00000000  r1 00000002  r2 00000008  r3 7a0efef0
D/CrashAnrDetector(831):     r4 6d6a4800  r5 00000000  r6 4025df88  r7 00000000
D/CrashAnrDetector(831):     r8 7b1d6b10  r9 791d3cc4  sl 79265220  fp 7b1d6b24
D/CrashAnrDetector(831):     ip 401f004c  sp 7b1d6ac8  lr 4172f41f  pc 4172f426  cpsr 600f0030
D/CrashAnrDetector(831):     d0  0000000000000000  d1  0000000000000000
D/CrashAnrDetector(831):     d2  0000000000000000  d3  0000000000000000
D/CrashAnrDetector(831):     d4  0100000000000000  d5  0000001000020000
D/CrashAnrDetector(831):     d6  3e4ccccd01fe1000  d7  400000004bfb9b10
D/CrashAnrDetector(831):     d8  0000000000000000  d9  0000000000000000
D/CrashAnrDetector(831):     d10 0000000000000000  d11 0000000000000000
D/CrashAnrDetector(831):     d12 0000000000000000  d13 0000000000000000
D/CrashAnrDetector(831):     d14 0000000000000000  d15 0000000000000000
D/CrashAnrDetector(831):     d16 0064006e00650073  d17 002e0067006e0069
D/CrashAnrDetector(831):     d18 006f006900730072  d19 00310027003d006e
D/CrashAnrDetector(831):     d20 002000270030002e  d21 006f0063006e0065
D/CrashAnrDetector(831):     d22 0067006e00690064  d23 007400750027003d
D/CrashAnrDetector(831):     d24 0031003200320031  d25 0036003500340033
D/CrashAnrDetector(831):     d26 0000000000000000  d27 0000000000000000
D/CrashAnrDetector(831):     d28 001e001d001c001b  d29 0020001f001d001e
D/CrashAnrDetector(831):     d30 0036003600360036  d31 0000000000000000
D/CrashAnrDetector(831):     scr 80000013
D/CrashAnrDetector(831): backtrace:
D/CrashAnrDetector(831):     #00  pc 0004f426  /system/lib/libdvm.so
D/CrashAnrDetector(831):     #01  pc 00001dad  /system/lib/libnativehelper.so (jniGetFDFromFileDescriptor+80)
D/CrashAnrDetector(831):     #02  pc 00075d11  /system/lib/libandroid_runtime.so
D/CrashAnrDetector(831):     #03  pc 00020e4c  /system/lib/libdvm.so (dvmPlatformInvoke+112)
D/CrashAnrDetector(831):     #04  pc 00051aef  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
D/CrashAnrDetector(831):     #05  pc 00000214  /dev/ashmem/dalvik-jit-code-cache (deleted)

Solution

  • You can't get the stack trace for code written in the Java programming language out of a native stack trace in the Dalvik VM, for the simple reason that Dalvik uses different pieces of memory for the native and managed stacks. (I believe it's possible to get it from Art crashes, because Art uses a shared stack, but can't say for certain.)

    The fault address suggests a null pointer dereference, and the call through jniGetFDFromFileDescriptor() indicates file activity. You can see the source code for that method here. I would guess it's calling GetIntField on a null object, which would match with your suspicions.

    Enabling CheckJNI may help -- if the JNI checker spots a problem, it will usually dump the current thread's stack trace to the log file before killing the VM.