Android AsyncTask致命信号11

时间:2014-08-23 14:56:06

标签: android multithreading asynchronous android-asynctask

有时,运行AsyncTask时会出现分段错误错误:

Fatal signal 11 (SIGSEGV) at 0x006e006f (code=1), thread 1864

完整筹码:

 Fatal signal 11 (SIGSEGV) at 0x00680063 (code=1), thread 2323 (Thread-155)
 *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
 Build fingerprint: 'generic/sdk/generic:4.4.2/KK/938007:eng/test-keys'
 Revision: '0'
 pid: 2308, tid: 2323, name: Thread-155  >>> xxxxxx <<<
 signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00680063
     r0 00680063  r1 b7be2238  r2 b3f71f20  r3 00760069
     r4 b3f71f20  r5 b3f71f20  r6 00000001  r7 b7be2238
     r8 b6fce028  r9 00000001  sl 00c52307  fp 00000000
     ip 00000000  sp ab501b60  lr b5b21174  pc b5b2135c  cpsr 20000010
     d0  bff0000000000000  d1  bff0000000000000
     d2  0000000000000000  d3  3fe0000000000000
     d4  3ff0000000000000  d5  3ff0000000000000
     d6  412e848000000000  d7  4000000040000000
     d8  0000000000000000  d9  0000000000000000
     d10 0000000000000000  d11 0000000000000000
     d12 0000000000000000  d13 0000000000000000
     d14 0000000000000000  d15 0000000000000000
     scr 60000010
 backtrace:
     #00  pc 0003735c  /system/lib/libdvm.so
     #01  pc 00037400  /system/lib/libdvm.so
     #02  pc 000293a8  /system/lib/libdvm.so (dvmCollectGarbageInternal(GcSpec const*)+340)
     #03  pc 00029e30  /system/lib/libdvm.so (dvmMalloc(unsigned int, int)+180)
     #04  pc 00068d87  /system/lib/libdvm.so
     #05  pc 00021f34  /system/lib/libdvm.so (dvmAsmSisterStart+500)
     #06  pc 0002df34  /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
     #07  pc 0002b5cc  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
     #08  pc 00060319  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
     #09  pc 0006033d  /system/lib/libdvm.so (dvmCallMethod(Thread*, Method const*, Object*, JValue*, ...)+20)
     #10  pc 0005502b  /system/lib/libdvm.so
     #11  pc 0000d060  /system/lib/libc.so (__thread_entry+72)
     #12  pc 0000d1f8  /system/lib/libc.so (pthread_create+240)
 stack:
          ab501b20  b3fe2fc4  /dev/ashmem/dalvik-heap (deleted)
          ab501b24  b5b212d4  /system/lib/libdvm.so
          ab501b28  b3fe2e00  /dev/ashmem/dalvik-heap (deleted)
          ab501b2c  00013e78  
          ab501b30  00004f9f  
          ab501b34  b7be2238  [heap]
          ab501b38  00000000  
          ab501b3c  80000000  
          ab501b40  b3aea0e0  /dev/ashmem/dalvik-zygote (deleted)
          ab501b44  b5b21174  /system/lib/libdvm.so
          ab501b48  b3f71f20  /dev/ashmem/dalvik-heap (deleted)
          ab501b4c  b5b991f0  /system/lib/libdvm.so
          ab501b50  b6fce0c0  /system/lib/libcutils.so
          ab501b54  b7be2238  [heap]
          ab501b58  b6fce028  /system/lib/libcutils.so
          ab501b5c  b5b21330  /system/lib/libdvm.so
     #00  ab501b60  b2f3f668  /dev/ashmem/dalvik-mark-stack (deleted)
          ab501b64  b7be2238  [heap]
          ab501b68  b7be2220  [heap]
          ab501b6c  b6fce0c0  /system/lib/libcutils.so
          ab501b70  b5b991f0  /system/lib/libdvm.so
          ab501b74  b5b21404  /system/lib/libdvm.so
     #01  ab501b78  b5b91c2c  /system/lib/libdvm.so
          ab501b7c  b5b133ac  /system/lib/libdvm.so (dvmCollectGarbageInternal(GcSpec const*)+344)
     #02  ab501b80  b3fb08b0  /dev/ashmem/dalvik-heap (deleted)
          ab501b84  000000c1  
          ab501b88  00000000  
          ab501b8c  00000050  
          ab501b90  00000050  
          ab501b94  b3daf008  /dev/ashmem/dalvik-heap (deleted)
          ab501b98  00000001  
          ab501b9c  00000050  
          ab501ba0  b5b991f0  /system/lib/libdvm.so
          ab501ba4  7fffffff  
          ab501ba8  b3fb08b0  /dev/ashmem/dalvik-heap (deleted)
          ab501bac  b5b5be19  /system/lib/libdvm.so (mspace_calloc+48)
          ab501bb0  ffffffff  
          ab501bb4  00000000  
          ab501bb8  00000000  
          ab501bbc  00000000  
          ........  ........

更详细的分析显示

/system/lib/libdvm.so (dvmCollectGarbageInternal(GcSpec const*)+340)

(GarbageCollection)导致异常。

asyncTask向服务器发出HTTP请求:

protected ArrayList<String> doInBackground(CallbackHolder... params)
{
    String responseString;
    HttpClient client = null;
    try
    {
        client = HttpClientFactory.createClient();
    }
    CallbackHolder callback = params[0];
    // some other stuff
}

CallbackHolder是一个更复杂的对象,它包含处理结果所需的一些对象。

不幸的是,调试非常困难,因为当应用程序崩溃时,分析结果不会写入磁盘。此外,无法调试异常,因为它位于本机libdvm.so

我的多线程可能有问题吗?

我只能说,当没有调用AsyncTask时,SIGSEGV不会出现。一旦我尝试访问CallbackHolder,应用程序就崩溃了? &lt; - 对此不确定。

有没有人有一些提示或改进提示?

0 个答案:

没有答案