diff --git a/src/bitbase.cpp b/src/bitbase.cpp index ebf3c59a..b3ae5c5f 100644 --- a/src/bitbase.cpp +++ b/src/bitbase.cpp @@ -85,9 +85,10 @@ bool Bitbases::probe(Square wksq, Square wpsq, Square bksq, Color us) { void Bitbases::init() { std::vector db(MAX_INDEX); + unsigned id = 0; // Initialize db with known win / draw positions - std::generate(db.begin(), db.end(), [](){ static unsigned id; return KPKPosition(id++); }); + std::generate(db.begin(), db.end(), [&id](){ return KPKPosition(id++); }); // Iterate through the positions until none of the unknown positions can be // changed to either wins or draws (15 cycles needed). diff --git a/src/thread.cpp b/src/thread.cpp index ef5ae857..048f2a7a 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -299,9 +299,12 @@ void ThreadPool::init() { void ThreadPool::exit() { delete_thread(timer); // As first because check_time() accesses threads data + timer = nullptr; for (Thread* th : *this) delete_thread(th); + + clear(); // Get rid of stale pointers }