当shell脚本执行时,android程序崩溃了

时间:2012-08-09 18:05:56

标签: android

我创建了使用cp adb shell命令复制文件的备份脚本。经过几天的测试,我真的很困惑,因为有时程序崩溃,我只是不知道为什么。我该怎么做才能避免这个问题?

每次复制完成后我都会刷新自定义BaseAdapter。使用notifyDataSetChanged()或meybe后,我不认为它是绘制视图问题?在我的LogCat输出下面。

当循环执行命令后,命令我得到了很多绿色(INFO / DEBUG)信息,然后我的程序崩溃......

...
DEBUG/exec  cp /data/app/org.apache.android.media-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/org.apache.android.media.apk
DEBUG/exec  cp /data/app/com.cyrilmottier.android.listviewtipsandtricks-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/com.cyrilmottier.android.listviewtipsandtricks.apk
DEBUG/exec  cp /data/app/org.alexis.littre-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/org.alexis.littre.apk
DEBUG/exec  cp /data/app/jp.susatthi.ManifestViewer-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/jp.susatthi.ManifestViewer.apk
DEBUG/exec  cp /data/app/com.mxtech.videoplayer.ad-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/com.mxtech.videoplayer.ad.apk
DEBUG/exec  cp /data/app/com.rerware.android.MyBackupRoot-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/com.rerware.android.MyBackupRoot.apk
INFO/DEBUG  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
INFO/DEBUG  Build fingerprint: 'samsung/GT-I9000/GT-I9000/GT-I9000:2.2/FROYO/XWJPH:user/release-keys'
INFO/DEBUG  pid: 8761, tid: 8761  >>> pl.backup <<<
INFO/DEBUG  signal 11 (SIGSEGV), fault addr 00001fd8
INFO/DEBUG   r0 00000035  r1 482347e0  r2 003fbf80  r3 4003fbf8
INFO/DEBUG   r4 007f7f00  r5 00001fa0  r6 bef5a240  r7 00001f84
INFO/DEBUG   r8 00000000  r9 000001fb  10 4003fbf8  fp 4818e7b8
INFO/DEBUG   ip 4b58caa7  sp bef5a1f8  lr 4b58ccdb  pc 4b58c690  cpsr 28000030
INFO/DEBUG   d0  6472656767756265  d1  0000005a41400000
INFO/DEBUG   d2  0000003c00000003  d3  0044abb800000001
INFO/DEBUG   d4  0000000000000000  d5  0000000000000000
INFO/DEBUG   d6  0000000100000001  d7  408000003f800000
INFO/DEBUG   d8  4194000041900000  d9  3ff0000000000012
INFO/DEBUG   d10 3ff0000000000000  d11 0000000000000000
INFO/DEBUG   d12 0000000000000000  d13 0000000000000000
INFO/DEBUG   d14 0000000000000000  d15 0000000000000000
INFO/DEBUG   d16 0000000700000000  d17 c053000000000000
INFO/DEBUG   d18 0000000000000000  d19 0000000000000000
INFO/DEBUG   d20 3ff0000000000000  d21 8000000000000000
INFO/DEBUG   d22 0000000000000000  d23 0006000300070002
INFO/DEBUG   d24 0101010101010101  d25 0000000000000000
INFO/DEBUG   d26 0016001600170016  d27 0016001600170016
INFO/DEBUG   d28 002f002e002f002e  d29 3ff0000000000000
INFO/DEBUG   d30 0000000000000000  d31 3ff0000000000000
INFO/DEBUG   scr 60000012
DEBUG/exec  cp /data/app/com.androidemu.n64-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/com.androidemu.n64.apk
DEBUG/exec  cp /data/app/com.androidemu.nes-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/com.androidemu.nes.apk
INFO/DEBUG           #00  pc 4b58c690  /dev/ashmem/dalvik-jit-code-cache (deleted)
INFO/DEBUG           #01  lr 4b58ccdb  /dev/ashmem/dalvik-jit-code-cache (deleted)
INFO/DEBUG  code around pc:
INFO/DEBUG  4b58c670 01000100 00280000 4321c584 01020018 
INFO/DEBUG  4b58c680 43dcdd1a 49190054 f2a568b0 2800071c 
INFO/DEBUG  4b58c690 63e963a8 c703d010 a1094c13 f7aea20a 
INFO/DEBUG  4b58c6a0 e011ed78 f8d7e008 290000ec 6ef7dc01 
INFO/DEBUG  4b58c6b0 a10347b8 ecf2f7ae 6df1480b 1c2d4788 
INFO/DEBUG  code around lr:
INFO/DEBUG  4b58ccb8 1c0800cc 1c116029 071cf2a5 606a2800 
INFO/DEBUG  4b58ccc8 c703d010 a1094c13 f7aea20a e011ea5e 
INFO/DEBUG  4b58ccd8 f8d7e008 29000698 6ef7dc01 a10347b8 
INFO/DEBUG  4b58cce8 e9d8f7ae 6df1480b 1c2d4788 4300e047 
INFO/DEBUG  4b58ccf8 43cecc74 0000e7fe 00000000 00000000 
INFO/DEBUG  stack:
INFO/DEBUG      bef5a1b8  40020e00  /dev/ashmem/mspace/dalvik-heap/zygote/0 (deleted)
INFO/DEBUG      bef5a1bc  80945327  /system/lib/libdvm.so
INFO/DEBUG      bef5a1c0  430cb368  
INFO/DEBUG      bef5a1c4  440990a5  /system/framework/framework.odex
INFO/DEBUG      bef5a1c8  00000000  
INFO/DEBUG      bef5a1cc  8094d7c7  /system/lib/libdvm.so
INFO/DEBUG      bef5a1d0  809a23f4  /system/lib/libdvm.so
INFO/DEBUG      bef5a1d4  00000001  
INFO/DEBUG      bef5a1d8  00000001  
INFO/DEBUG      bef5a1dc  00000008  
INFO/DEBUG      bef5a1e0  430cb304  
INFO/DEBUG      bef5a1e4  43d3e79a  /system/framework/framework.odex
INFO/DEBUG      bef5a1e8  43cece82  /system/framework/framework.odex
INFO/DEBUG      bef5a1ec  80973339  /system/lib/libdvm.so
INFO/DEBUG      bef5a1f0  df002777  
INFO/DEBUG      bef5a1f4  e3a070ad  
INFO/DEBUG  #00 bef5a1f8  438bc000  /system/framework/core.odex
INFO/DEBUG      bef5a1fc  bef5a240  [stack]
INFO/DEBUG      bef5a200  0028cb90  [heap]
INFO/DEBUG      bef5a204  0000cd38  [heap]
INFO/DEBUG      bef5a208  000361b0  [heap]
INFO/DEBUG      bef5a20c  000003a0  
INFO/DEBUG      bef5a210  809a22e0  /system/lib/libdvm.so
INFO/DEBUG      bef5a214  809a6ee0  /system/lib/libdvm.so
INFO/DEBUG      bef5a218  bef5a4e8  [stack]
INFO/DEBUG      bef5a21c  80922798  /system/lib/libdvm.so
INFO/DEBUG      bef5a220  0000cd30  [heap]
INFO/DEBUG      bef5a224  bef5a240  [stack]
INFO/DEBUG      bef5a228  8092271c  /system/lib/libdvm.so
INFO/DEBUG      bef5a22c  00000000  
INFO/DEBUG      bef5a230  000003a0  
INFO/DEBUG      bef5a234  80921638  /system/lib/libdvm.so
INFO/DEBUG      bef5a238  bef5a3ac  [stack]
INFO/DEBUG      bef5a23c  bef5a3ac  [stack]
DEBUG/exec  cp /data/app/com.opera.browser-1.apk /mnt/sdcard/allbackup/backup/2012-08-09_18@51@47!63/apps/com.opera.browser.apk
INFO/DEBUG  dumpmesg > /data/log/dumpstate_app_native.log
INFO/BootReceiver   Copying /data/tombstones/tombstone_00 to DropBox (SYSTEM_TOMBSTONE)
INFO/dumpstate  begin
DEBUG/dalvikvm  GC_FOR_MALLOC freed 15878 objects / 1113800 bytes in 802ms
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
INFO/dalvikvm   threadid=3: reacting to signal 3
ERROR/dalvikvm  Failed to write stack traces to /data/anr/traces.txt (379 of 2308
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   threadid=3: reacting to signal 3
ERROR/dalvikvm  Failed to write stack traces to /data/anr/traces.txt (1785 of 2784
ERROR/dalvikvm  Failed to write stack traces to /data/anr/traces.txt (-1 of 3335
ERROR/dalvikvm  Failed to write stack traces to /data/anr/traces.txt (-1 of 2316
ERROR/dalvikvm  Failed to write stack traces to /data/anr/traces.txt (-1 of 2337
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
ERROR/dalvikvm  Failed to write stack traces to /data/anr/traces.txt (1870 of 4332
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
INFO/dalvikvm   Wrote stack traces to '/data/anr/traces.txt'
DEBUG/SntpClient    request time failed: java.net.UnknownHostException: north-america.pool.ntp.org
DEBUG/SntpClient    request time failed: java.net.UnknownHostException: north-america.pool.ntp.org
DEBUG/SntpClient    request time failed: java.net.UnknownHostException: north-america.pool.ntp.org
DEBUG/VoldCmdListener   asec list
INFO/dumpstate  done
DEBUG/Zygote    Process 8761 terminated by signal (11)

2 个答案:

答案 0 :(得分:0)

这是由于内存引用无效。我建议它与一些本地库有关。这就是信号11的含义。我认为很可能不是在java代码中。我猜的更有可能是一个包含的jni库。

另见SIGNAL 11 SIGSEGV crash Android

您可能需要清除缓存。达到缓存限制是另一种可能性。

要了解更多信息,您可以使用ndk-stack打印出应用的崩溃转储。 阅读ndk目录中的docs \ NDK-STACK.html,了解有关使用它的完整步骤。

也可能是固件:请参阅Android Java App Crashing with SIGSEGV

答案 1 :(得分:0)

请看看这种感觉:

工作精细:

while(true) {   
    long czas = android.os.SystemClock.uptimeMillis();
    Storage.executeCmd("cp /data/app/com.rerware.android.MyBackupRoot-1.apk /mnt/sdcard/allbackup/backup/aplikacja"+String.valueOf(czas)+".apk", null);
}   

工作精细:

while(true) {   
    Message msg = new Message(); // customadapter.notifydatachanged() in main activity
    msg.arg1 = 1;
    mHandler.sendMessage(msg);
}   

2分钟后崩溃(睡眠= 100)

while(true) {   
    long czas = android.os.SystemClock.uptimeMillis();           
    Storage.executeCmd("cp /data/app/com.rerware.android.MyBackupRoot-1.apk /mnt/sdcard/allbackup/backup/aplikacja"+String.valueOf(czas)+".apk", null);
    sleep(100);

    Message msg = new Message(); // customadapter.notifydatachanged in main activity
    msg.arg1 = 1;
    mHandler.sendMessage(msg);
    Log.d("ods test", "ods test");                  
    sleep(100); 
}   

25分钟后崩溃(睡眠= 200)

while(true) {   
    long czas = android.os.SystemClock.uptimeMillis();           
    Storage.executeCmd("cp /data/app/com.rerware.android.MyBackupRoot-1.apk /mnt/sdcard/allbackup/backup/aplikacja"+String.valueOf(czas)+".apk", null);
    sleep(200);

    Message msg = new Message(); // customadapter.notifydatachanged in main activity
    msg.arg1 = 1;
    mHandler.sendMessage(msg);
    Log.d("ods test", "ods test");               
    sleep(200);
}
一个问题WHAAAAAAAAAT?必须有进程冲突...因为cp命令在ps列表中创建新进程

PS:1000ms延迟似乎工作精细(测试2h)