I'm building an Android app with 5 activities and one application (pseudo-singleton) containing a chunk of ndk code. I've recently added a few routines in the ndk, all of which are stable, but since then my app has been acting erratically: my singleton seems to reset, and my activity goes back a level for reasons I have yet to figure out. One of the things that's hindering my understanding is that the debugger is disconnecting. No warning, no "source not found" message... poof! gone!
Has anyone come across this problem? Any advice?
EDIT:
I've added the Logcat of the event when attached to my phone (Nexus S). It records a crash, but still don't know why:
06-22 15:09:26.469: DEBUG/dalvikvm(10791): GC_CONCURRENT freed 683K, 53% free 3181K/6663K, external 2055K/2137K, paused 2ms+3ms
06-22 15:09:27.324: INFO/ActivityManager(115): Displayed edu.upenn.jime.infApp/.ShowPlot: +1s7ms
06-22 15:09:31.418: INFO/ActivityManager(115): Start proc com.whatsapp for service com.whatsapp/.messaging.MessageService: pid=10889 uid=10092 gids={1015, 3003}
06-22 15:09:32.195: INFO/DEBUG(10706): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
06-22 15:09:32.195: INFO/DEBUG(10706): Build fingerprint: 'google/soju/crespo:2.3.4/GRJ22/121341:user/release-keys'
06-22 15:09:32.195: INFO/DEBUG(10706): pid: 10791, tid: 10791 >>> edu.upenn.jime.infApp <<<
06-22 15:09:32.195: INFO/DEBUG(10706): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000020
06-22 15:09:32.199: INFO/DEBUG(10706): r0 00000000 r1 ffffffff r2 00000000 r3 00000008
06-22 15:09:32.199: INFO/DEBUG(10706): r4 000619a8 r5 421bb214 r6 00000000 r7 ffffffff
06-22 15:09:32.203: INFO/DEBUG(10706): r8 00000008 r9 bed3d540 10 fffffe84 fp fffffe84
06-22 15:09:32.203: INFO/DEBUG(10706): ip 80043c41 sp bed3d440 lr 80031cac pc 80043c52 cpsr 60000030
06-22 15:09:32.203: INFO/DEBUG(10706): d0 000000000000037c d1 00000040bed3d300
06-22 15:09:32.203: INFO/DEBUG(10706): d2 0049002e00690000 d3 0066007200750000
06-22 15:09:32.203: INFO/DEBUG(10706): d4 0000000000000000 d5 0000000100000000
06-22 15:09:32.203: INFO/DEBUG(10706): d6 0000000000000001 d7 0000000000000000
06-22 15:09:32.203: INFO/DEBUG(10706): d8 3fd0d32894e2c335 d9 0000000000000000
06-22 15:09:32.203: INFO/DEBUG(10706): d10 0000000000000000 d11 0000000000000000
06-22 15:09:32.203: INFO/DEBUG(10706): d12 0000000000000000 d13 0000000000000000
06-22 15:09:32.203: INFO/DEBUG(10706): d14 0000000000000000 d15 0000000000000000
06-22 15:09:32.203: INFO/DEBUG(10706): d16 000000c240038350 d17 c053000000000000
06-22 15:09:32.203: INFO/DEBUG(10706): d18 0000000000000000 d19 0000000000000000
06-22 15:09:32.203: INFO/DEBUG(10706): d20 3ff0000000000000 d21 8000000000000000
06-22 15:09:32.215: INFO/DEBUG(10706): d22 0000000000000000 d23 ff00000000000000
06-22 15:09:32.215: INFO/DEBUG(10706): d24 ff00000000000000 d25 ff00000000000000
06-22 15:09:32.215: INFO/DEBUG(10706): d26 0100010001000100 d27 0100010001000100
06-22 15:09:32.215: INFO/DEBUG(10706): d28 0100010001000100 d29 3ff0000000000000
06-22 15:09:32.215: INFO/DEBUG(10706): d30 0000000000000000 d31 3ff0000000000000
06-22 15:09:32.215: INFO/DEBUG(10706): scr 2000001a
06-22 15:09:32.285: INFO/DEBUG(10706): #00 pc 00043c52 /system/lib/libdvm.so
06-22 15:09:32.285: INFO/DEBUG(10706): #01 pc 00031ca8 /system/lib/libdvm.so
06-22 15:09:32.285: INFO/DEBUG(10706): code around pc:
06-22 15:09:32.285: INFO/DEBUG(10706): 80043c30 f9daf7ff e9c39b02 20010100 bf00bd10
06-22 15:09:32.285: INFO/DEBUG(10706): 80043c40 41f0e92d 68004605 4c1a4698 b08a460f
06-22 15:09:32.285: INFO/DEBUG(10706): 80043c50 6a034616 0599447c 2302d501 2301e000
06-22 15:09:32.285: INFO/DEBUG(10706): 80043c60 3008f88d fa62f7ff c04cf8df 17fb463a
06-22 15:09:32.285: INFO/DEBUG(10706): 80043c70 2308e9cd 95062200 300cf854 4330f8d3
06-22 15:09:32.285: INFO/DEBUG(10706): code around lr:
06-22 15:09:32.285: INFO/DEBUG(10706): 80031c8c e59d1078 e1a00008 ebffbc84 e3e01000
06-22 15:09:32.285: INFO/DEBUG(10706): 80031c9c e3a03008 e1a02000 e59d0020 eb01551e
06-22 15:09:32.285: INFO/DEBUG(10706): 80031cac eaffde80 e1a0200a e1a03005 e1a00008
06-22 15:09:32.285: INFO/DEBUG(10706): 80031cbc e1a01004 e58d6000 ebffdb3d eaffdea9
06-22 15:09:32.285: INFO/DEBUG(10706): 80031ccc e59d2024 e7913002 e5931370 e3510000
06-22 15:09:32.285: INFO/DEBUG(10706): stack:
06-22 15:09:32.285: INFO/DEBUG(10706): bed3d400 bed3d458
06-22 15:09:32.285: INFO/DEBUG(10706): bed3d404 00000000
06-22 15:09:32.285: INFO/DEBUG(10706): bed3d408 bed3d4e8
06-22 15:09:32.285: INFO/DEBUG(10706): bed3d40c 4214ce14
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d410 bed3d438
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d414 4214ce0c
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d418 fffffe84
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d41c ad34675f /system/lib/libandroid_runtime.so
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d420 00000000
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d424 0000037c
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d428 0011da48
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d42c ad34676b /system/lib/libandroid_runtime.so
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d430 bed3d458
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d434 80017e38 开发者_如何学编程 /system/lib/libdvm.so
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d438 df002777
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d43c e3a070ad
06-22 15:09:32.289: INFO/DEBUG(10706): #00 bed3d440 bed3d4e8
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d444 4214ce08
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d448 0000ce60
06-22 15:09:32.289: INFO/DEBUG(10706): bed3d44c 00000001
06-22 15:09:32.293: INFO/DEBUG(10706): bed3d450 bed3d4e8
06-22 15:09:32.293: INFO/DEBUG(10706): bed3d454 80049697 /system/lib/libdvm.so
06-22 15:09:32.293: INFO/DEBUG(10706): bed3d458 4214ce08
06-22 15:09:32.293: INFO/DEBUG(10706): bed3d45c 431f2903
06-22 15:09:32.301: INFO/DEBUG(10706): bed3d460 ad346761 /system/lib/libandroid_runtime.so
06-22 15:09:32.301: INFO/DEBUG(10706): bed3d464 bed3d4e8
06-22 15:09:32.301: INFO/DEBUG(10706): bed3d468 42f8b182
06-22 15:09:32.301: INFO/DEBUG(10706): bed3d46c 4214cdf4
06-22 15:09:32.301: INFO/DEBUG(10706): bed3d470 0000ce60
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d474 4214ce08
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d478 421bb31c
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d47c 80031cac /system/lib/libdvm.so
06-22 15:09:32.304: INFO/DEBUG(10706): #01 bed3d480 421bb214
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d484 0000000c
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d488 4214ccf0
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d48c 40167900
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d490 27cabd5f
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d494 00000135
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d498 4060be80
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d49c 800a5600
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d4a0 421bb214
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d4a4 fffffe84
06-22 15:09:32.304: INFO/DEBUG(10706): bed3d4a8 40016d08
06-22 15:09:32.308: INFO/DEBUG(10706): bed3d4ac 0004dbd8
06-22 15:09:32.308: INFO/DEBUG(10706): bed3d4b0 00000015
06-22 15:09:32.308: INFO/DEBUG(10706): bed3d4b4 00000000
06-22 15:09:32.308: INFO/DEBUG(10706): bed3d4b8 0000ae20
06-22 15:09:32.308: INFO/DEBUG(10706): bed3d4bc 800a3588
06-22 15:09:32.308: INFO/DEBUG(10706): bed3d4c0 800a3588
06-22 15:09:32.308: INFO/DEBUG(10706): bed3d4c4 800a3588
06-22 15:09:32.660: INFO/BootReceiver(115): Copying /data/tombstones/tombstone_06 to DropBox (SYSTEM_TOMBSTONE)
06-22 15:09:32.676: INFO/WindowManager(115): WIN DEATH: Window{40a80190 edu.upenn.jime.infApp/edu.upenn.jime.infApp.Simulate paused=false}
06-22 15:09:32.676: INFO/WindowManager(115): WIN DEATH: Window{409996b8 edu.upenn.jime.infApp/edu.upenn.jime.infApp.Inf paused=false}
06-22 15:09:32.676: INFO/WindowManager(115): WIN DEATH: Window{40a6d0c8 edu.upenn.jime.infApp/edu.upenn.jime.infApp.CalcInf paused=false}
06-22 15:09:32.679: INFO/ActivityManager(115): Process edu.upenn.jime.infApp (pid 10791) has died.
06-22 15:09:32.691: INFO/ActivityManager(115): Start proc edu.upenn.jime.infApp for activity edu.upenn.jime.infApp/.CalcInf: pid=10901 uid=10118 gids={}
06-22 15:09:32.699: DEBUG/Zygote(75): Process 10791 terminated by signal (11)
06-22 15:09:32.793: DEBUG/dalvikvm(10901): Trying to load lib /data/data/edu.upenn.jime.infApp/lib/libinfApp.so 0x40514540
06-22 15:09:32.801: DEBUG/dalvikvm(10901): Added shared lib /data/data/edu.upenn.jime.infApp/lib/libinfApp.so 0x40514540
06-22 15:09:32.801: DEBUG/dalvikvm(10901): No JNI_OnLoad found in /data/data/edu.upenn.jime.infApp/lib/libinfApp.so 0x40514540, skipping init
06-22 15:09:32.859: WARN/InputManagerService(115): Got RemoteException sending setActive(false) notification to pid 10791 uid 10118
06-22 15:09:32.937: INFO/ActivityManager(115): Displayed edu.upenn.jime.infApp/.CalcInf: +253ms
06-22 15:09:33.140: INFO/dalvikvm(10889): Could not find method android.media.MediaMetadataRetriever.captureFrame, referenced from method com.whatsapp.u5.a
06-22 15:09:33.140: WARN/dalvikvm(10889): VFY: unable to resolve virtual method 428: Landroid/media/MediaMetadataRetriever;.captureFrame ()Landroid/graphics/Bitmap;
06-22 15:09:33.140: DEBUG/dalvikvm(10889): VFY: replacing opcode 0x6e at 0x012f
06-22 15:09:33.148: DEBUG/dalvikvm(10889): VFY: dead code 0x0132-0138 in Lcom/whatsapp/u5;.a (Landroid/app/Activity;Lcom/whatsapp/am;Ljava/lang/String;Ljava/io/File;BLjava/lang/String;)Z
06-22 15:09:34.957: DEBUG/dalvikvm(10889): GC_CONCURRENT freed 846K, 50% free 3406K/6727K, external 1625K/2137K, paused 10ms+3ms
I should also mention that the code was working fine up until I added a couple more routines in the NDK(went from 5 to 7) that link with the GSL library. The routines execute fine and return correct data, and the crash does not always happen immediately after their execution
It took a fair bit of effort but I figured out the issue: I passed an array to ndk which was too small for the function. Instead of throwing a Seg fault then and there, it kept on humming for a few more minutes, or even hours. Then suddenly the whole application collapses with no warning and the last working intent gets loaded.
This was a real pain as the tombstone/stacktrace gave no useful information. Unlike a typical seg fault in Java/Android, the screen displays nothing out of the ordinary.
are you outputting to the log? A lot of time when the debugger detaches its due to null reference!
if that isn't the issue, i would suggest deleting the current emulator and creating a new one. sometimes they can get buggy and this usually gives you a fresh state to work with.
精彩评论