1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 08:13:08 +00:00

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>
This commit is contained in:
Marco Costalba 2011-12-11 10:07:16 +01:00
parent 91601d7f95
commit 377c406c74

View file

@ -100,6 +100,7 @@ CheckInfo::CheckInfo(const Position& pos) {
void Position::copy(const Position& pos, int th) {
memcpy(this, &pos, sizeof(Position));
st = &startState;
threadID = th;
nodes = 0;