From 10b52e77b0608d1468c095bcb491a84790205a53 Mon Sep 17 00:00:00 2001 From: AbdelRauf Date: Mon, 1 Mar 2021 13:38:43 +0100 Subject: [PATCH] fix segfault: parallel_do tries to acquire numThreads-1 threads. And there are cases it wanted to get 0 threads. And it was falsely returning back valid ticket because of missing conditions. Here how it was happening in real run: There are functions where nested threading can happen. So in segfault case (example:gather op) outer threading acquired all threads. and as inner functions tried to acquire threads themselves. And as the inner function was using faulty parallel_do it seg faulted. Signed-off-by: AbdelRauf --- libnd4j/include/execution/impl/ThreadPool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnd4j/include/execution/impl/ThreadPool.cpp b/libnd4j/include/execution/impl/ThreadPool.cpp index 890fd0f08..438c29011 100644 --- a/libnd4j/include/execution/impl/ThreadPool.cpp +++ b/libnd4j/include/execution/impl/ThreadPool.cpp @@ -151,7 +151,7 @@ namespace samediff { Ticket* ThreadPool::tryAcquire(int numThreads) { //std::vector*> queues; - + if(numThreads<=0) return nullptr; Ticket *t = nullptr; // we check for threads availability first bool threaded = false;