From: Marco Costalba Date: Tue, 12 Oct 2010 07:54:01 +0000 (+0200) Subject: Pass moveCount by value in split() X-Git-Url: https://git.sesse.net/?p=stockfish;a=commitdiff_plain;h=79a7647fe0124c0c0647e203c7cc984e98f21c21 Pass moveCount by value in split() 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 --- diff --git a/src/search.cpp b/src/search.cpp index 6ec744c8..9d1fe017 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -88,7 +88,7 @@ namespace { template 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(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 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++)