]> git.sesse.net Git - stockfish/commit
Fix a crash when quitting while searching
authorMarco Costalba <mcostalba@gmail.com>
Sun, 11 Dec 2011 09:07:16 +0000 (10:07 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Sun, 11 Dec 2011 09:31:46 +0000 (10:31 +0100)
commit377c406c748643d1aeec6a7ce9a45b32a7416bf3
tree1849137f09b09cdcf294a38a9bd8fbbba7b68d96
parent91601d7f95a3e84d2d46ca9a36637508197dbdab
Fix a crash when quitting while searching

The Position object used by UI thread is a local variable in
uci_loop(), so after receiving "quit" command the function
returns and the position is freed from the stack.

This should not be a problem becuase in start_thinking() we copy
the position to RootPosition that is the one used by main search
thread. Unfortunatly we blindly copy also StateInfo pointer that
still points to the startState struct inside UI position. So the
pointer becomes stale as soon as UI thread leaves uci_loop() and
because this happens while main search thread is still recovering
after the 'stop' signal we have a crash.

The fix is to update the pointer to the correct startState after
the copy.

Found with Valgrind.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/position.cpp