From 2bbf2421ad680caf53097ce73847ad503f5e64e5 Mon Sep 17 00:00:00 2001 From: PikaCat Date: Sun, 11 Aug 2024 22:18:21 +0800 Subject: [PATCH] Fix possible crashing due to tt race in legal. pseudo_legal does not handle cases where there is only one checker and the move in tt don't comply with the pattern generated by movegen. Causing legal() failed to work with needSlowCheck off. Crash report by @skystarspython --- src/position.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/position.cpp b/src/position.cpp index 309e1536..6474213e 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -183,8 +183,8 @@ void Position::set_check_info() const { Square ksq = king_square(~sideToMove); // We have to take special cares about the cannon and checks - st->needSlowCheck = more_than_one(checkers()) - || (attacks_bb(king_square(sideToMove)) & pieces(~sideToMove, CANNON)); + st->needSlowCheck = + checkers() || (attacks_bb(king_square(sideToMove)) & pieces(~sideToMove, CANNON)); st->checkSquares[PAWN] = pawn_attacks_to_bb(sideToMove, ksq); st->checkSquares[KNIGHT] = attacks_bb(ksq, pieces());