Skip to content

Commit

Permalink
Fix possible crashing due to tt race in legal.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
PikaCat-OuO committed Aug 11, 2024
1 parent 7f62ac8 commit 2bbf242
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/position.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ROOK>(king_square(sideToMove)) & pieces(~sideToMove, CANNON));
st->needSlowCheck =
checkers() || (attacks_bb<ROOK>(king_square(sideToMove)) & pieces(~sideToMove, CANNON));

st->checkSquares[PAWN] = pawn_attacks_to_bb(sideToMove, ksq);
st->checkSquares[KNIGHT] = attacks_bb<KNIGHT_TO>(ksq, pieces());
Expand Down

0 comments on commit 2bbf242

Please sign in to comment.