mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-18 16:16:23 +08:00
Fix a subtle bug due to the StateInfo pointer became stale
There was one occurence when the StateInfo variable went out of scope before the corresponding Position object. This yelds to a crash. Bug was not hit before because occurs only when using an UCI interface and not the usual benchmark. The fix consists in copying internally the content of the about to stale StateInfo. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
//// Includes
|
||||
////
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@@ -228,6 +229,9 @@ namespace {
|
||||
if (RootPosition.rule_50_counter() == 0)
|
||||
RootPosition.reset_game_ply();
|
||||
}
|
||||
// Our StateInfo st is about going out of scope,
|
||||
// so save its content before they disappear.
|
||||
RootPosition.setStartState(st);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,6 +325,8 @@ namespace {
|
||||
if (moveTime)
|
||||
infinite = true; // HACK
|
||||
|
||||
assert(RootPosition.is_ok());
|
||||
|
||||
think(RootPosition, infinite, ponder, RootPosition.side_to_move(), time,
|
||||
inc, movesToGo, depth, nodes, moveTime, searchMoves);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user