From b36a1fa1b4ffded06aba53e1003b40827c39803c Mon Sep 17 00:00:00 2001 From: Sami Kiminki Date: Tue, 19 May 2020 12:08:01 +0300 Subject: [PATCH 1/1] Avoid sending info strings before 'uci' has been received Do not send the following info string on the first call to aligned_ttmem_alloc() on Windows: info string Hash table allocation: Windows large pages [not] used. The first call occurs before the 'uci' command has been received. This confuses some GUIs, which expect the first engine-sent command to be 'id' as the response to the 'uci' command. (see https://github.com/official-stockfish/Stockfish/issues/2681) closes https://github.com/official-stockfish/Stockfish/pull/2689 No functional change. --- src/misc.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/misc.cpp b/src/misc.cpp index e0cc6ed5..c6254784 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -358,12 +358,21 @@ static void* aligned_ttmem_alloc_large_pages(size_t allocSize) { void* aligned_ttmem_alloc(size_t allocSize, void*& mem) { + static bool firstCall = true; + // try to allocate large pages mem = aligned_ttmem_alloc_large_pages(allocSize); - if (mem) - sync_cout << "info string Hash table allocation: Windows large pages used." << sync_endl; - else - sync_cout << "info string Hash table allocation: Windows large pages not used." << sync_endl; + + // Suppress info strings on the first call. The first call occurs before 'uci' + // is received and in that case this output confuses some GUIs. + if (!firstCall) + { + if (mem) + sync_cout << "info string Hash table allocation: Windows large pages used." << sync_endl; + else + sync_cout << "info string Hash table allocation: Windows large pages not used." << sync_endl; + } + firstCall = false; // fall back to regular, page aligned, allocation if necessary if (!mem) -- 2.39.2