From 8a2c8c58cae676b57bd1c2178f519b67f92f717f Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Thu, 8 Oct 2015 16:45:21 +0200 Subject: [PATCH] Better fix of crash bug Crash is due to slave thread accessing main thread data while exiting. Fix it in the proper way makeing slave threads independent from main state. No functional change. --- src/thread.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/thread.cpp b/src/thread.cpp index 2b94cf7b..a35f521f 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -123,7 +123,7 @@ void Thread::idle_loop() { { std::unique_lock lk(mutex); - while (!Threads.main()->thinking && !exit) + while (!searching && !exit) sleepCondition.wait(lk); lk.unlock(); @@ -190,10 +190,8 @@ void ThreadPool::exit() { timer = nullptr; for (Thread* th : *this) - if (th != Threads.main()) - delete_thread(th); + delete_thread(th); - delete_thread(Threads.main()); // Must be the last one clear(); // Get rid of stale pointers }