mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-21 09:37:16 +08:00
Fix uninitialized memory usage
After increasing the number of threads, the histories were not cleared, resulting in uninitialized memory usage. This patch fixes this by clearing threads histories in Thread c'tor as is the idomatic way. This fixes issue 1227 No functional change.
This commit is contained in:
committed by
Marco Costalba
parent
7b4c9852e1
commit
e385f194e9
@@ -35,6 +35,7 @@ ThreadPool Threads; // Global object
|
||||
Thread::Thread(size_t n) : idx(n), stdThread(&Thread::idle_loop, this) {
|
||||
|
||||
wait_for_search_finished();
|
||||
clear(); // Zero-init histories (based on std::array)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +52,20 @@ Thread::~Thread() {
|
||||
}
|
||||
|
||||
|
||||
/// Thread::clear() reset histories, usually before a new game
|
||||
|
||||
void Thread::clear() {
|
||||
|
||||
counterMoves.fill(MOVE_NONE);
|
||||
mainHistory.fill(0);
|
||||
|
||||
for (auto& to : contHistory)
|
||||
for (auto& h : to)
|
||||
h.fill(0);
|
||||
|
||||
contHistory[NO_PIECE][0].fill(Search::CounterMovePruneThreshold - 1);
|
||||
}
|
||||
|
||||
/// Thread::start_searching() wakes up the thread that will start the search
|
||||
|
||||
void Thread::start_searching() {
|
||||
|
||||
Reference in New Issue
Block a user