From 0374e40745ca85a75cb1d163437eb67180674120 Mon Sep 17 00:00:00 2001 From: AndyGrant Date: Sun, 9 Jul 2017 18:13:19 -0400 Subject: [PATCH] Fixed an engine crash, and an uninitalized value error Ethereal would crash upon recieving a position command, if its length exceeded 2048 characters. I felt confident that no position would go that long, but I was wrong. The limit is now 8192 characters, which is ~2000 moves. I would be shocked to see a game go that long before adjudicating Sometimes the LPV would not be filled during IID, causing bad values to be used as the table move. I could not find a case where fixing the issue changed the node counts, but it resolves the valgrind complaints none the less --- src/search.c | 2 +- src/uci.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/search.c b/src/search.c index b01735c8..389f556b 100644 --- a/src/search.c +++ b/src/search.c @@ -389,7 +389,7 @@ int alphaBetaSearch(PVariation * pv, Board * board, int alpha, int beta, value = alphaBetaSearch(&lpv, board, -MATE, beta, depth-2, height, PVNODE); // Get the best move from the PV - tableMove = lpv.line[0]; + if (lpv.length >= 1) tableMove = lpv.line[0]; // Update tableIsTactical for LMR tableIsTactical = moveIsTactical(board, tableMove); diff --git a/src/uci.c b/src/uci.c index 9703a08f..2bafc16a 100644 --- a/src/uci.c +++ b/src/uci.c @@ -48,7 +48,7 @@ int main(){ Undo undo[1]; SearchInfo info; uint16_t moves[MAX_MOVES]; - char str[2048], moveStr[6], testStr[6], * ptr; + char str[8192], moveStr[6], testStr[6], * ptr; // Initalze all components of the chess engine initalizeMagics(); @@ -82,7 +82,7 @@ int main(){ http://wbec-ridderkerk.nl/html/UCIProtocol.html */ if (stringEquals(str, "uci")){ - printf("id name Ethereal 8.20\n"); + printf("id name Ethereal 8.21\n"); printf("id author Andrew Grant\n"); printf("option name Hash type spin default 16 min 1 max 2048\n"); printf("uciok\n"); @@ -315,7 +315,7 @@ int stringContains(char * str, char * key){ void getInput(char * str){ - if (fgets(str, 2048, stdin) == NULL) + if (fgets(str, 8192, stdin) == NULL) exit(EXIT_FAILURE); char * ptr = strchr(str, '\n');