diff --git a/Eigen/src/Core/products/Parallelizer.h b/Eigen/src/Core/products/Parallelizer.h index 3123dc94a..67b2442b5 100644 --- a/Eigen/src/Core/products/Parallelizer.h +++ b/Eigen/src/Core/products/Parallelizer.h @@ -132,7 +132,8 @@ void parallelize_gemm(const Functor& func, Index rows, Index cols, Index depth, ei_declare_aligned_stack_constructed_variable(GemmParallelInfo,info,threads,0); - #pragma omp parallel num_threads(threads) + int errorCount = 0; + #pragma omp parallel num_threads(threads) reduction(+: errorCount) { Index i = omp_get_thread_num(); // Note that the actual number of threads might be lower than the number of request ones. @@ -151,9 +152,14 @@ void parallelize_gemm(const Functor& func, Index rows, Index cols, Index depth, info[i].lhs_start = r0; info[i].lhs_length = actualBlockRows; - if(transpose) func(c0, actualBlockCols, 0, rows, info); - else func(0, rows, c0, actualBlockCols, info); + EIGEN_TRY { + if(transpose) func(c0, actualBlockCols, 0, rows, info); + else func(0, rows, c0, actualBlockCols, info); + } EIGEN_CATCH(...) { + ++errorCount; + } } + if (errorCount) EIGEN_THROW_X(Eigen::eigen_assert_exception()); #endif } diff --git a/test/exceptions.cpp b/test/exceptions.cpp index b83fb82ba..015b9fd33 100644 --- a/test/exceptions.cpp +++ b/test/exceptions.cpp @@ -109,5 +109,7 @@ void memoryleak() void test_exceptions() { - CALL_SUBTEST( memoryleak() ); + EIGEN_TRY { + CALL_SUBTEST( memoryleak() ); + } EIGEN_CATCH(...) {} }