]> git.sesse.net Git - stockfish/blobdiff - src/thread.cpp
Fix a crash when 'go' multiple times
[stockfish] / src / thread.cpp
index 782cf1acc0dd5153fb8ba3bebad8cf69bc35da12..b7bead9ff0c867627105cb0eb8ee9ffa328c733e 100644 (file)
@@ -366,10 +366,14 @@ void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits,
   Signals.stopOnPonderhit = Signals.firstRootMove = false;
   Signals.stop = Signals.failedLowAtRoot = false;
 
+  RootMoves.clear();
   RootPos = pos;
   Limits = limits;
-  SetupStates = states; // Ownership transfer here
-  RootMoves.clear();
+  if (states.get()) // If we don't set a new position, preserve current state
+  {
+      SetupStates = states; // Ownership transfer here
+      assert(!states.get());
+  }
 
   for (MoveList<LEGAL> it(pos); *it; ++it)
       if (   searchMoves.empty()