mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 02:57:11 +08:00
Fix a race when extracting PV from TT
Because TT table is shared tte->move() could change under our feet, in particular we could validate tte->move() then the move is changed by another thread and we call pos.do_move() with a move different from the original validated one ! This leads to a very rare but reproducible crash once every about 20K games. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -1767,14 +1767,14 @@ void RootMove::extract_pv_from_tt(Position& pos) {
|
||||
pos.do_move(m, *st++);
|
||||
|
||||
while ( (tte = TT.probe(pos.key())) != NULL
|
||||
&& tte->move() != MOVE_NONE
|
||||
&& pos.is_pseudo_legal(tte->move())
|
||||
&& pos.pl_move_is_legal(tte->move(), pos.pinned_pieces())
|
||||
&& (m = tte->move()) != MOVE_NONE // Local copy, TT entry could change
|
||||
&& pos.is_pseudo_legal(m)
|
||||
&& pos.pl_move_is_legal(m, pos.pinned_pieces())
|
||||
&& ply < MAX_PLY
|
||||
&& (!pos.is_draw<false>() || ply < 2))
|
||||
{
|
||||
pv.push_back(tte->move());
|
||||
pos.do_move(tte->move(), *st++);
|
||||
pv.push_back(m);
|
||||
pos.do_move(m, *st++);
|
||||
ply++;
|
||||
}
|
||||
pv.push_back(MOVE_NONE);
|
||||
|
||||
Reference in New Issue
Block a user