]> git.sesse.net Git - stockfish/commitdiff
Pass moveCount by value in split()
authorMarco Costalba <mcostalba@gmail.com>
Tue, 12 Oct 2010 07:54:01 +0000 (09:54 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Tue, 12 Oct 2010 11:33:44 +0000 (12:33 +0100)
Actually it is an error to update back moveCount value after split()
because it is used in update_history() to access movesSearched[]
array. But becasue this vector is not updated in the split point
we end up with an access of stale data.

Bug has been hidden til now because we 'forgot' to update
moveCount before returning from split().

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/search.cpp

index 6ec744c859596415703fa8bef8e520f7eba47879..9d1fe0173ed7500cbe0d1e2bc9216454d8b6696d 100644 (file)
@@ -88,7 +88,7 @@ namespace {
 
     template <bool Fake>
     void split(const Position& pos, SearchStack* ss, int ply, Value* alpha, const Value beta, Value* bestValue,
-               Depth depth, Move threatMove, bool mateThreat, int* moveCount, MovePicker* mp, bool pvNode);
+               Depth depth, Move threatMove, bool mateThreat, int moveCount, MovePicker* mp, bool pvNode);
 
   private:
     friend void poll();
@@ -1342,7 +1342,7 @@ namespace {
           && !ThreadsMgr.thread_should_stop(threadID)
           && Iteration <= 99)
           ThreadsMgr.split<FakeSplit>(pos, ss, ply, &alpha, beta, &bestValue, depth,
-                                      threatMove, mateThreat, &moveCount, &mp, PvNode);
+                                      threatMove, mateThreat, moveCount, &mp, PvNode);
     }
 
     // Step 19. Check for mate and stalemate
@@ -2560,7 +2560,7 @@ namespace {
   template <bool Fake>
   void ThreadsManager::split(const Position& p, SearchStack* ss, int ply, Value* alpha,
                              const Value beta, Value* bestValue, Depth depth, Move threatMove,
-                             bool mateThreat, int* moveCount, MovePicker* mp, bool pvNode) {
+                             bool mateThreat, int moveCount, MovePicker* mp, bool pvNode) {
     assert(p.is_ok());
     assert(ply > 0 && ply < PLY_MAX);
     assert(*bestValue >= -VALUE_INFINITE);
@@ -2600,7 +2600,7 @@ namespace {
     splitPoint.pvNode = pvNode;
     splitPoint.bestValue = *bestValue;
     splitPoint.mp = mp;
-    splitPoint.moveCount = *moveCount;
+    splitPoint.moveCount = moveCount;
     splitPoint.pos = &p;
     splitPoint.parentSstack = ss;
     for (i = 0; i < ActiveThreads; i++)