mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +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:
parent
91601d7f95
commit
377c406c74
1 changed files with 1 additions and 0 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue