From 7a2a1cf40ec66970c17e7fb4eba421c756fe06ce Mon Sep 17 00:00:00 2001 From: PikaCat Date: Thu, 14 Nov 2024 21:53:36 +0800 Subject: [PATCH] Avoid wrongful TT/history updates when unwinding the search during a thread stop Probcut does not have the same logic that exists in the primary move loop during pvsearch, which guards against acting on invalid scores from child nodes. With this, it does. The solution, and the comment, are copy-pasted from the other location. --- src/search.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/search.cpp b/src/search.cpp index 712aefc3..638d9206 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -819,6 +819,11 @@ Value Search::Worker::search( if (value >= probCutBeta) { + // If a stop occurred, the return value of the search cannot be trusted, and we + // must return immediately without updating any histories nor the transposition table. + if (threads.stop.load(std::memory_order_relaxed)) + return VALUE_ZERO; + thisThread->captureHistory[movedPiece][move.to_sq()][type_of(captured)] << stat_bonus(depth - 2);