]> git.sesse.net Git - stockfish/commit
Wait for main thread to finish before to exit
authorMarco Costalba <mcostalba@gmail.com>
Thu, 29 Dec 2011 08:55:09 +0000 (09:55 +0100)
committerMarco Costalba <mcostalba@gmail.com>
Thu, 29 Dec 2011 09:33:06 +0000 (10:33 +0100)
commit9cb187762a68e431559ee9e4b1ed8c6f16826d89
tree3b2456621e3dacf2f537dbebf8f2caee5922fbd9
parent4a8c1b24702ddf577853d72962cee6735a0235da
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>
src/thread.cpp
src/thread.h
src/uci.cpp