1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-11 19:49:14 +00: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:
Marco Costalba 2012-02-17 20:38:17 +01:00
parent fd35d92c1e
commit d8349f9d0f

View file

@ -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);