]> git.sesse.net Git - stockfish/commitdiff
Start a TT resize only after search finished.
authorJoost VandeVondele <Joost.VandeVondele@gmail.com>
Sat, 8 Dec 2018 22:03:42 +0000 (23:03 +0100)
committerStéphane Nicolet <cassio@free.fr>
Sun, 16 Dec 2018 08:41:09 +0000 (09:41 +0100)
As noticed in the forum, a crash in extract_ponder_from_tt could result
if hash size is set before the ponder move is printed. While it is arguably
a GUI issue (but it got me on the cli), it is easy to avoid this issue.

Closes https://github.com/official-stockfish/Stockfish/pull/1856

No functional change.

src/thread.cpp
src/tt.cpp

index e69120842c58f0be117c0b16e2c7800b14f54d26..f88e359b0373436db1f6c445f72f4b04448667e7 100644 (file)
@@ -136,10 +136,10 @@ void ThreadPool::set(size_t requested) {
       while (size() < requested)
           push_back(new Thread(size()));
       clear();
-  }
 
-  // Reallocate the hash with the new threadpool size
-  TT.resize(Options["Hash"]);
+      // Reallocate the hash with the new threadpool size
+      TT.resize(Options["Hash"]);
+  }
 }
 
 /// ThreadPool::clear() sets threadPool data to initial values.
index 716d13e0695b9c108ba142879c365f573e027a73..50e8a3bfac4bad1bcf72ee61d79664d2db36fbe8 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "bitboard.h"
 #include "misc.h"
+#include "thread.h"
 #include "tt.h"
 #include "uci.h"
 
@@ -58,6 +59,8 @@ void TTEntry::save(Key k, Value v, Bound b, Depth d, Move m, Value ev) {
 
 void TranspositionTable::resize(size_t mbSize) {
 
+  Threads.main()->wait_for_search_finished();
+
   clusterCount = mbSize * 1024 * 1024 / sizeof(Cluster);
 
   free(mem);