From 86853a60cea0c786c8e69bc27ffc102659cb31ad Mon Sep 17 00:00:00 2001 From: "Robert Nurnberg @ elitebook" <28635489+robertnurnberg@users.noreply.github.com> Date: Sun, 26 Apr 2026 09:28:45 +0200 Subject: [PATCH] [bugfix] Send correct search depth in final UCI info line For quite some time SF has reported a too low final search depth in rare cases (in multi-threaded search if a non-main thread was selected). Unfortunately, the recent refactoring in #6704 means that this now happens for almost every stopped search. This PR fixes this issue, which was first spotted and reported by joergoster, by ensuring that `rootDepth` always holds the last depth for which a search was started. Fixes #6756. closes https://github.com/official-stockfish/Stockfish/pull/6761 No functional change. --- src/search.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/search.cpp b/src/search.cpp index 50aa07708..abb229eaf 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -247,7 +247,7 @@ void Search::Worker::start_searching() { // Send PV info if it has changed since last output in iterative_deepening(). if (!uciPvSent || bestThread != this) - main_manager()->pv(*bestThread, threads, tt, bestThread->completedDepth); + main_manager()->pv(*bestThread, threads, tt, bestThread->rootDepth); // In rare cases, pv() may change the ponder move through syzygy_extend_pv(). std::string ponder; @@ -322,9 +322,11 @@ bool Search::Worker::iterative_deepening() { mainHistory[c][i] = mainHistory[c][i] * 820 / 1024; // Iterative deepening loop until requested to stop or the target depth is reached - while (++rootDepth < MAX_PLY && !threads.stop - && !(limits.depth && mainThread && rootDepth > limits.depth)) + while (rootDepth + 1 < MAX_PLY && !threads.stop + && !(limits.depth && mainThread && rootDepth >= limits.depth)) { + rootDepth++; + // Age out PV variability metric and signal the start of a new iteration. if (mainThread) {