尝试使用某些并行计算时遇到以下错误:
SIGSEGV (signal SIGSEGV: invalid address (fault address: 0x430000))
我的方法的一部分"产生"这个错误看起来如下:
...
...
task1 = new FutureTask<>(() -> {
Core.inRange(hsvMat, new Scalar(0, 120, 120), new Scalar(11, 255, 255), lowerColor);
return true;
});
task2 = new FutureTask<>(() -> {
Core.inRange(hsvMat, new Scalar(171, 120, 120), new Scalar(184, 255, 255), upperColor);
return true;
});
executor.execute(task1);
executor.execute(task2);
try {
if (task1.get() && task2.get()) {
executor.shutdown();
Core.add(lowerColor, upperColor, mixedColors);
}
return mixedColors;
返回mixedColors
时会发生此错误,但仅在调试模式下发生。在没有调试的情况下启动应用程序时,它会通过但没有任何结果,就像这个功能没有发生一样。
没有FutureTask<>
的代码工作正常,因此必须存在一些问题,但我不知道是什么。我将不胜感激任何建议。
编辑:
我设法检索了这个堆栈跟踪,但仍未找到解决方案。
java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@fc427ad rejected from java.util.concurrent.ThreadPoolExecutor@1fbd017[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 2]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2014)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:794)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1340)
at ....SignDetector.filterColorRange(SignDetector.java:465)
at ....utils.SignDetector.runDetectionFor(SignDetector.java:173)
at ....view.DetectorActivity.lambda$-pl_th_mobileroadassistant_view_DetectorActivity_lambda$1(DetectorActivity.java:125)
at ....view.-$Lambda$0.$m$0(Unknown Source)
at ....view.-$Lambda$0.run(Unknown Source)
at java.lang.Thread.run(Thread.java:818)
at ....view.DetectorActivity.onCameraFrame(DetectorActivity.java:123)
at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:387)
at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:350)
at java.lang.Thread.run(Thread.java:818)