diff options
Diffstat (limited to 'src/testsup.c')
| -rw-r--r-- | src/testsup.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/testsup.c b/src/testsup.c index 3ed50e3..d1b102d 100644 --- a/src/testsup.c +++ b/src/testsup.c @@ -87,7 +87,25 @@ GenerateRandomLegalPosition(POSITION *pos) { pos->cNonPawns[WHITE][u] = pos->cNonPawns[BLACK][u] = ILLEGAL_COOR; } - + + // memset above zeroes cEpSquare to 0x00 (A8), a real on-board + // square, not the "no en passant" sentinel -- every random + // position generated by this function had a bogus "en passant + // available on a8" flag set regardless of whether that made + // any sense. Both the mailbox and bitboard pawn generators + // trust this field and will act on it (mailbox: any pawn whose + // normal diagonal-capture target happens to coincide with a8; + // bitboard: proactively, once per side per node, since + // _GenerateAllPawnMovesBB/_SaveMeAllPawnMovesBB gate their + // en-passant block on IS_ON_BOARD(cEpSquare) directly) -- + // constructing a garbage "en passant capture" move whenever a + // pawn of the right color happens to sit on b7 by pure chance, + // which corrupts position state and was traced back to an + // intermittent TestSearch segfault (board_representation/ + // MOVEGEN_MIGRATION.md section 6b). + pos->cEpSquare = ILLEGAL_COOR; + + // // Place both kings legally // |
