X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fthread.cpp;h=16bda2809147f9d299d9b425ae8d00d9997ff071;hp=8269dcf3d50029d2e4e355a8da8c345b48ddee80;hb=ac7339877b3e083b5dd93f34ec79779d43f784ae;hpb=d156e7a20b4ea15c2cbb4bcfa2dca5f1e96ece3b diff --git a/src/thread.cpp b/src/thread.cpp index 8269dcf3..16bda280 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -192,14 +192,19 @@ void ThreadsManager::init() { void ThreadsManager::exit() { + // Wake up all the slave threads at once. This is faster than "wake and wait" + // for each thread and avoids a rare crash once every 10K games under Linux. + for (int i = 1; i < MAX_THREADS; i++) + { + threads[i].do_terminate = true; + threads[i].wake_up(); + } + for (int i = 0; i < MAX_THREADS; i++) { - // Wake up all the slave threads and wait for termination if (i != 0) { - threads[i].do_terminate = true; - threads[i].wake_up(); - + // Wait for slave termination #if defined(_MSC_VER) WaitForSingleObject(threads[i].handle, 0); CloseHandle(threads[i].handle); @@ -248,7 +253,7 @@ template Value ThreadsManager::split(Position& pos, SearchStack* ss, Value alpha, Value beta, Value bestValue, Depth depth, Move threatMove, int moveCount, MovePicker* mp, int nodeType) { - assert(pos.is_ok()); + assert(pos.pos_is_ok()); assert(bestValue >= -VALUE_INFINITE); assert(bestValue <= alpha); assert(alpha < beta);