mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 16:53:09 +00:00
Fix a crash when 'go' multiple times
Search is started after setting a position and issuing UCI 'go' command. Then if we stop the search and call 'go' again without setting a new position it is assumed that the previous setup is preserved, but this is not the case because what happens is that SetupStates is reset to NULL, leading to a crash as soon as RootPos.is_draw() is called because st->previous is now stale. UCI protocol is not very clear about requiring that a position is setup always before launching a search, so here we easy the life of GUI developers assuming that the current state is preserved after returning from a 'stop' command. Bug reported by Gregor Cramer. No functional change.
This commit is contained in:
parent
46409a7852
commit
2a98042c21
1 changed files with 6 additions and 2 deletions
|
@ -366,10 +366,14 @@ void ThreadPool::start_thinking(const Position& pos, const LimitsType& limits,
|
|||
Signals.stopOnPonderhit = Signals.firstRootMove = false;
|
||||
Signals.stop = Signals.failedLowAtRoot = false;
|
||||
|
||||
RootMoves.clear();
|
||||
RootPos = pos;
|
||||
Limits = limits;
|
||||
SetupStates = states; // Ownership transfer here
|
||||
RootMoves.clear();
|
||||
if (states.get()) // If we don't set a new position, preserve current state
|
||||
{
|
||||
SetupStates = states; // Ownership transfer here
|
||||
assert(!states.get());
|
||||
}
|
||||
|
||||
for (MoveList<LEGAL> it(pos); *it; ++it)
|
||||
if ( searchMoves.empty()
|
||||
|
|
Loading…
Add table
Reference in a new issue