Introduce a constant for ValueList size in search()

Having the size of these lists in two separate places likely contributed
to the crashes seen during the recent tuning attempt
https://tests.stockfishchess.org/tests/view/685c413343ce022d15794536.

Thanks to @MinetaS for spotting this.

closes https://github.com/official-stockfish/Stockfish/pull/6142

No functional change
This commit is contained in:
Robert Nurnberg @ elitebook
2025-06-26 17:19:09 +02:00
committed by Disservin
parent 3a0fff96cf
commit 84e2f3851d

View File

@@ -63,6 +63,9 @@ using namespace Search;
namespace {
constexpr int SEARCHEDLIST_CAPACITY = 32;
using SearchedList = ValueList<Move, SEARCHEDLIST_CAPACITY>;
// (*Scalers):
// The values with Scaler asterisks have proven non-linear scaling.
// They are optimized to time controls of 180 + 1.8 and longer,
@@ -124,8 +127,8 @@ void update_all_stats(const Position& pos,
Search::Worker& workerThread,
Move bestMove,
Square prevSq,
ValueList<Move, 32>& quietsSearched,
ValueList<Move, 32>& capturesSearched,
SearchedList& quietsSearched,
SearchedList& capturesSearched,
Depth depth,
Move TTMove,
int moveCount);
@@ -605,8 +608,8 @@ Value Search::Worker::search(
int priorReduction;
Piece movedPiece;
ValueList<Move, 32> capturesSearched;
ValueList<Move, 32> quietsSearched;
SearchedList capturesSearched;
SearchedList quietsSearched;
// Step 1. Initialize node
Worker* thisThread = this;
@@ -1390,7 +1393,7 @@ moves_loop: // When in check, search starts here
// If the move is worse than some previously searched move,
// remember it, to update its stats later.
if (move != bestMove && moveCount <= 32)
if (move != bestMove && moveCount <= SEARCHEDLIST_CAPACITY)
{
if (capture)
capturesSearched.push_back(move);
@@ -1838,8 +1841,8 @@ void update_all_stats(const Position& pos,
Search::Worker& workerThread,
Move bestMove,
Square prevSq,
ValueList<Move, 32>& quietsSearched,
ValueList<Move, 32>& capturesSearched,
SearchedList& quietsSearched,
SearchedList& capturesSearched,
Depth depth,
Move ttMove,
int moveCount) {