当插件在Java中创建新线程时扑扑

时间:2019-03-27 04:17:37

标签: flutter

我有一个颤抖的项目,并且我创建了一个插件,该插件将创建新线程来执行任务并返回通道结果(正常运行几秒钟,例如,可以执行,ping或cmd)。

在dart中,当我递归地同时调用插件几次(5、10、20 ..)(每次都会在Java中创建几个新线程)时,该应用将在随机的一段时间后崩溃并输出错误。我不知道问题出在哪里。

方法通道响应在新线程中返回,我打印了Thread.activeNumber,当我每次循环调用该插件5次时,它停留在21到25之间,因此线程数没有增加。

这是我的插件代码的摘录:

try {
  Thread thread = new Thread(new Runnable() {
    @Override
    public void run() {
      res.success(doCURLRequest(input));
      return;
    }
  });
  thread.start();
} catch (Exception e) {
  e.printStackTrace();
  result.error(e.toString(), "", null);
}

这是控制台的输出:

F/libc    (25280): Fatal signal 11 (SIGSEGV), code 1, fault addr 
0x1f0ffed65f03d0 in tid 25280 (nieben.yiqice)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'HONOR/LLD-AL30/HWLLD-H2:8.0.0/HONORLLD- 
AL30/133(C00):user/release-keys'
Revision: '0'
ABI: 'arm64'
pid: 25280, tid: 25280, name: nieben.yiqice  >>> nieben.yiqice <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1f0ffed65f03d0
    x0   0000000000000060  x1   0000007c8f437dc0  x2   0000007c8f400000  x3   0000000000000006
    x4   0000000000000037  x5   0000007fc10ce078  x6   0000007cb8f23000  x7   0000000022794276
    x8   0000007c96de9898  x9   0000000000000016  x10  0000000000000016  x11  0000000000000009
    x12  0000007c965a0c40  x13  0000000000000010  x14  0000007c965a0c40  x15  f81f0ffed65f03c0
    x16  000000009109c108  x17  0000007cb7ce7948  x18  000000001a5a3a48  x19  0000007cb417f388
    x20  0000000000000017  x21  0000000000000017  x22  000000000000000b  x23  0000000000000044
    x24  000000000000000b  x25  0000007cb417f398  x26  0000007cb40ade70  x27  0000007ca9a0e818
    x28  0000000000000040  x29  0000007ca9a0e818  x30  0000007c965b4810
    sp   0000007fc10ce0f0  pc   0000007c96cee860  pstate 0000000020000000
backtrace:
    #00 pc 00000000013e6860  /data/app/nieben.yiqice-kHJTi3gGe9hMTdLsxaaXXQ==/lib/arm64/libflutter.so (offset 0xc90000)
    #01 pc 0000000000cac80c  /data/app/nieben.yiqice-kHJTi3gGe9hMTdLsxaaXXQ==/lib/arm64/libflutter.so (offset 0xc90000)
    #02 pc 0000000000cac540  /data/app/nieben.yiqice-kHJTi3gGe9hMTdLsxaaXXQ==/lib/arm64/libflutter.so (offset 0xc90000)
    #03 pc 0000000000cac260  /data/app/nieben.yiqice-kHJTi3gGe9hMTdLsxaaXXQ==/lib/arm64/libflutter.so (offset 0xc90000)
    #04 pc 0000000000ce6154  /data/app/nieben.yiqice-kHJTi3gGe9hMTdLsxaaXXQ==/lib/arm64/libflutter.so (offset 0xc90000)
    #05 pc 0000000000cb9d60  /data/app/nieben.yiqice-kHJTi3gGe9hMTdLsxaaXXQ==/lib/arm64/libflutter.so (offset 0xc90000)
    #06 pc 0000000000cbba94  /data/app/nieben.yiqice-kHJTi3gGe9hMTdLsxaaXXQ==/lib/arm64/libflutter.so (offset 0xc90000)
    #07 pc 0000000000015f18  /system/lib64/libutils.so (_ZN7android6Looper9pollInnerEi+808)
    #08 pc 0000000000015b68  /system/lib64/libutils.so (_ZN7android6Looper8pollOnceEiPiS1_PPv+108)
    #09 pc 000000000011b31c  /system/lib64/libandroid_runtime.so (_ZN7androidL38android_os_MessageQueue_nativePollOnceEP7_JNIEnvP8_jobjectli+44)
    #10 pc 000000000082769c  /system/framework/arm64/boot-framework.oat (offset 0x626000) (android.app.NativeActivity.onWindowFocusChangedNative [DEDUPED]+140)
    #11 pc 0000000000015c50  /dev/ashmem/dalvik-jit-code-cache (deleted)

类似测试的另一项输出:

F/libc    (23487): Fatal signal 7 (SIGBUS), code 1, fault addr 0x63656600000029 in t
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'HONOR/LLD-AL30/HWLLD-H2:8.0.0/HONORLLD-AL30/133(C00):user/releas
Revision: '0'
ABI: 'arm64'
pid: 23487, tid: 23533, name: Thread-16  >>> nieben.yiqice <<<
signal 7 (SIGBUS), code 1 (BUS_ADRALN), fault addr 0x63656600000029
    x0   0000007c8ebeb6e0  x1   0000007cb7ce6c00  x2   0000000000000000  x3   000000
    x4   0000000000000099  x5   0000000000000000  x6   0000007cb8f23000  x7   000000
    x8   7463656600000029  x9   0000000000000002  x10  0000000000000001  x11  000000
    x12  0000000000000000  x13  ffffffffffffffb0  x14  000026254eac6a09  x15  00000f
    x16  0000007c96f166a0  x17  0000007cb7ce7948  x18  0000000000000179  x19  000000
    x20  0000007c92fc3248  x21  0000007c8ebeb6e0  x22  0000007c92fc3240  x23  000000
    x24  0000007c874a5a00  x25  0000000000000050  x26  0000007c874a6000  x27  000000
    x28  0000000000000002  x29  0000007cb402db78  x30  0000007c96694aa8
    sp   0000007c959bf000  pc   0063656600000029  pstate 0000000060000000
backtrace:
    #00 pc 0063656600000029  <unknown>
    #01 pc 0000000000cd4aa4  /data/app/nieben.yiqice-kCfddpl3R270LR1KEPCNIw==/lib/ar
    #02 pc 0000000000cb9d60  /data/app/nieben.yiqice-kCfddpl3R270LR1KEPCNIw==/lib/ar
    #03 pc 0000000000cbba94  /data/app/nieben.yiqice-kCfddpl3R270LR1KEPCNIw==/lib/ar
    #04 pc 0000000000015f18  /system/lib64/libutils.so (_ZN7android6Looper9pollInner
    #05 pc 0000000000015b68  /system/lib64/libutils.so (_ZN7android6Looper8pollOnceE
    #06 pc 0000000000013944  /system/lib64/libandroid.so (ALooper_pollOnce+92)
    #07 pc 0000000000cbbb64  /data/app/nieben.yiqice-kCfddpl3R270LR1KEPCNIw==/lib/ar
    #08 pc 0000000000cb8d7c  /data/app/nieben.yiqice-kCfddpl3R270LR1KEPCNIw==/lib/ar
    #09 pc 0000000000cba2e4  /data/app/nieben.yiqice-kCfddpl3R270LR1KEPCNIw==/lib/ar
    #10 pc 00000000000671b8  /system/lib64/libc.so (_ZL15__pthread_startPv+36)
    #11 pc 000000000001eee4  /system/lib64/libc.so (__start_thread+68)

0 个答案:

没有答案