Skip to content

Commit

Permalink
Fixed an engine crash, and an uninitalized value error
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AndyGrant committed Jul 9, 2017
1 parent 6fbc0e0 commit 0374e40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/search.c
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/uci.c
Expand Up @@ -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();
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit 0374e40

Please sign in to comment.