From 2717bfd67bdedc7c29bbc80dccfdae2aa2be4960 Mon Sep 17 00:00:00 2001 From: Andrew Grant Date: Tue, 1 Oct 2024 22:44:24 -0400 Subject: [PATCH] Fix bug with wrong tt entry write during exit unwind Bench 1173651 --- src/search.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/search.cpp b/src/search.cpp index a206cddab3d..909413e23ef 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -895,6 +895,11 @@ Value Search::Worker::search( pos.undo_move(move); + // 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; + if (value >= probCutBeta) { thisThread->captureHistory[movedPiece][move.to_sq()][type_of(captured)]