Skip to content

Commit 011494f

Browse files
author
syzygy
committed
Fix crash in bench when SyzygyPath is set.
1 parent 82cafa5 commit 011494f

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/benchmark.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,13 @@ void benchmark(Pos *current, char *str)
169169
uint64_t nodes = 0;
170170
Pos pos;
171171
pos.stack = malloc(101 * sizeof(Stack)); // max perft 100
172+
pos.stack++;
172173
pos.moveList = malloc(10000 * sizeof(ExtMove));
173174
TimePoint elapsed = now();
174175

175176
for (size_t i = 0; i < num_fens; i++) {
176177
pos_set(&pos, fens[i], option_value(OPT_CHESS960));
178+
(pos.st-1)->endMoves = pos.moveList;
177179

178180
fprintf(stderr, "\nPosition: %" FMT_Z "u/%" FMT_Z "u\n", i + 1, num_fens);
179181

@@ -202,7 +204,7 @@ void benchmark(Pos *current, char *str)
202204
free(fens[i]);
203205
free(fens);
204206
}
205-
free(pos.stack);
207+
free(pos.stack - 1);
206208
free(pos.moveList);
207209
}
208210

src/position.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,18 @@ void do_move(Pos *pos, Move m, int givesCheck)
10631063
st->key = key;
10641064

10651065
// Calculate checkers bitboard (if move gives check)
1066+
#if 1
10661067
st->checkersBB = givesCheck
10671068
? attackers_to(square_of(them, KING)) & pieces_c(us) : 0;
1069+
#else
1070+
st->checkersBB = 0;
1071+
if (givesCheck) {
1072+
if (type_of_m(m) != NORMAL || ((st-1)->blockersForKing[them] & sq_bb(from)))
1073+
st->checkersBB = attackers_to(square_of(them, KING)) & pieces_c(us);
1074+
else
1075+
st->checkersBB = (st-1)->checkSquares[piece & 7] & sq_bb(to);
1076+
}
1077+
#endif
10681078

10691079
pos->sideToMove ^= 1;
10701080

0 commit comments

Comments
 (0)