5

My Java app has a JNI layer for communicating with a native C++ library. When the app is idle for approximately three (3) minutes, the app crashes, with LogCat showing the following stack trace:

07-13 13:21:35.876: A/libc(9889): Fatal signal 11 (SIGSEGV) at 0x606b0ba4 (code=1), thread 9889 (nc.myapp)
07-13 13:21:35.980: I/DEBUG(4710): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-13 13:21:35.980: I/DEBUG(4710): Build fingerprint: 'motorola/ghost_retail/ghost:4.4.3/KXA21.12-L1.21/23:user/release-keys'
07-13 13:21:35.981: I/DEBUG(4710): Revision: 'p300'
07-13 13:21:35.983: I/DEBUG(4710): pid: 9889, tid: 9889, name: nc.myapp  >>> com.company.myapp <<<
07-13 13:21:35.984: I/DEBUG(4710): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 606b0ba4
07-13 13:21:36.093: I/DEBUG(4710):     r0 00000001  r1 0018c020  r2 60b8ec1c  r3 00001204
07-13 13:21:36.093: I/DEBUG(4710):     r4 00000001  r5 60485008  r6 60b70ce8  r7 00000000
07-13 13:21:36.093: I/DEBUG(4710):     r8 606b0cd6  r9 00000001  sl 60485010  fp 00000000
07-13 13:21:36.094: I/DEBUG(4710):     ip 00000000  sp 606b0b98  lr 6099ed68  pc 6099ed74  cpsr 200d0010
07-13 13:21:36.094: I/DEBUG(4710):     d0  0000000000000001  d1  0000001100000012
07-13 13:21:36.094: I/DEBUG(4710):     d2  0000000000000000  d3  000000040000005c
07-13 13:21:36.094: I/DEBUG(4710):     d4  0041002e00770065  d5  0061005300730062
07-13 13:21:36.094: I/DEBUG(4710):     d6  0053006400650076  d7  0065007400610074
07-13 13:21:36.094: I/DEBUG(4710):     d8  440b00000000022c  d9  0000000042fe0000
07-13 13:21:36.095: I/DEBUG(4710):     d10 0000000000000000  d11 0000000000000000
07-13 13:21:36.095: I/DEBUG(4710):     d12 0000000000000000  d13 0000000000000000
07-13 13:21:36.095: I/DEBUG(4710):     d14 0000000000000000  d15 0000000000000000
07-13 13:21:36.095: I/DEBUG(4710):     d16 0074006900760069  d17 006e0061004d0079
07-13 13:21:36.095: I/DEBUG(4710):     d18 0061006c006f0072  d19 007800690070002e
07-13 13:21:36.096: I/DEBUG(4710):     d20 00690070006c0065  d21 0049002e00650070
07-13 13:21:36.096: I/DEBUG(4710):     d22 0065007800690050  d23 007000690050006c
07-13 13:21:36.096: I/DEBUG(4710):     d24 000e000d000c000b  d25 0010000f000d000e
07-13 13:21:36.096: I/DEBUG(4710):     d26 0000000000000000  d27 0000000000000000
07-13 13:21:36.097: I/DEBUG(4710):     d28 0148014701450146  d29 0149014a014a0149
07-13 13:21:36.097: I/DEBUG(4710):     d30 0010001000100010  d31 0000000000000000
07-13 13:21:36.097: I/DEBUG(4710):     scr 20000013
07-13 13:21:36.098: I/DEBUG(4710): backtrace:
07-13 13:21:36.098: I/DEBUG(4710):     #00  pc 000b1d74  /data/app-lib/com.company.myapp-1/libwrappersjni.so
07-13 13:21:36.098: I/DEBUG(4710):     #01  pc 000b1d64  /data/app-lib/com.v-1/libwrappersjni.so

The crash seems to indicate the crash is occurring in my shared library, libwrappersjni.so. I have a linker map file, creating through using the -XLinker and -Map gcc linker options. The map file lists symbols with a relative offset, for example:

 .ARM.extab.text.Java_com_hyperlync_myapp_WrappersApi_logout
                0x00224e1c        0xc ./obj/local/armeabi/objs/wrappersjni/jni_Wrappers.o
 .ARM.extab.text.Java_com_hyperlync_myapp_WrappersApi_signout
                0x00224e28        0xc ./obj/local/armeabi/objs/wrappersjni/jni_Wrappers.o
 .ARM.extab.text.Java_com_hyperlync_myapp_WrappersApi_uploadFileInt
                0x00224e34       0x20 ./obj/local/armeabi/objs/wrappersjni/jni_Wrappers.o

What I seem to be missing is the actual address my app was loaded into memory. if I knew that I would subtract the loading address from the pc (Program Counter) register to pinpoint the crash code location.

Is there an intuitive method for manually mapping the absolute crash address found in the pc register to an entry in the linker map file?

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
Moshe Rubin
  • 1,944
  • 1
  • 17
  • 37
  • 2
    Why do it manually, you have `addr2line` utility in NDK toolchain, and even a special wrapper, `ndk-stack`. _[Here](http://bytesthink.com/blog/?p=133)_ are instructoins. – Alex Cohn Jul 13 '14 at 20:19
  • 1
    @Alex You are, of course, correct. When I initially tried to use add2line passing it the value in the pc register, it returned gibberish like "?:0, ??:0". So I thought I'd go the manually path. A short while ago, when I passed it other addresses found in the stack trace, it returned meaningful symbols which enabled me to solve the problem. Many thanks for your response, I'm wiser now. – Moshe Rubin Jul 13 '14 at 20:23
  • The values in the stack trace are offsets from the start of the library, the value in PC is an absolute value in memory. – fadden Jul 14 '14 at 15:48

0 Answers0