mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 09:06:45 +08:00
Wait for main thread to finish before to exit
Currently after a 'quit' command UI thread raises stop signal, exits from uci_loop() and calls Threads.exit() while the search threads are still active. In Threads.exit() main thread is asked to terminate, but if it is parked in idle_loop() it will exit and free its resources (in particular the shared Movepicker object) while sibling slaves are still active and this leads to a crash. The fix is to let the UI thread always wait for main thread to finish the search before to return from uci_loop(). Found by Valgrind when running with 8 threads. No functional change. Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
@@ -68,10 +68,7 @@ void uci_loop() {
|
||||
is >> skipws >> token;
|
||||
|
||||
if (token == "quit" || token == "stop")
|
||||
{
|
||||
Search::Signals.stop = true;
|
||||
Threads[0].wake_up(); // In case is waiting for stop or ponderhit
|
||||
}
|
||||
Threads.stop_thinking();
|
||||
|
||||
else if (token == "ponderhit")
|
||||
{
|
||||
@@ -81,9 +78,7 @@ void uci_loop() {
|
||||
Search::Limits.ponder = false;
|
||||
|
||||
if (Search::Signals.stopOnPonderhit)
|
||||
Search::Signals.stop = true;
|
||||
|
||||
Threads[0].wake_up(); // In case is waiting for stop or ponderhit
|
||||
Threads.stop_thinking();
|
||||
}
|
||||
|
||||
else if (token == "go")
|
||||
|
||||
Reference in New Issue
Block a user