Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stockfish 15.1 crashes for: position fen 3qk1nb/1p3p2/p1r1p1p1/3p4/3P4/2N1BP2/PPPQ1P2/R3K3 w Qk - 0 15 #5071

Closed
Mercutio1243 opened this issue Feb 24, 2024 · 5 comments

Comments

@Mercutio1243
Copy link

Mercutio1243 commented Feb 24, 2024

Describe the issue

I am using stockfish_15.1_win_x64 from the official website. When running stockfish-windows-2022-x86-64.exe and prompting the commands:

position fen 3qk1nb/1p3p2/p1r1p1p1/3p4/3P4/2N1BP2/PPPQ1P2/R3K3 w Qk - 0 15
go movetime infinite

The exe crashes instantaneously. Similarly, my flutter app running with a flutter implementation of Stockfish 15.1 (https://pub.dev/packages/stockfish) crashes with an error pointing to the engine.

Other positions run through as expected.

Expected behavior

Stockfish calculates position and does not crash

Steps to reproduce

See above

Anything else?

No response

Operating system

All

Stockfish version

Stockfish 15.1

@Disservin
Copy link
Member

Disservin commented Feb 24, 2024

Your fen isn't a valid FEN. position fen 3qk1nb/1p3p2/p1r1p1p1/3p4/3P4/2N1BP2/PPPQ1P2/R3K3 w Qk - 0 15 Black cannot castle king side. There's a bishop in the corner not a rook.

@Mercutio1243
Copy link
Author

Thank you, this is a good pointer!

Why is Stockfish then accepting the following fen:
position fen 2rqk1nb/1p3p2/p1B1p1p1/3p4/3P4/2N1BP2/PPPQ1P2/R3K3 b Qk - 0 14

@Disservin
Copy link
Member

Probably because the king is in check and chess rules say we cant castle, so we dont try to generate the move and after the king moves we clear all castling squares for the king.

@PGG106
Copy link

PGG106 commented Feb 24, 2024

How the engine reacts to illegal fens should be considered undefined behaviour, you can't rely on the engine consistently saving itself from a crash.
If you want fen validation your best bet currently it to validate the fen before passing it to sf.

@Mercutio1243
Copy link
Author

Mercutio1243 commented Feb 24, 2024

Ok, thank you very much for the super fast response! I fully agree, the error is with the generation of the fens that I am using (not your problem).

For future reference below all the previous fens from that game that I am using were also faulty but did not result in an error. But again, not your issue as PGG106 is pointing out (but maybe interesting for someone else at some point).

rnbqk1nr/ppp1ppb1/6p1/3p4/8/2N5/PPPPPPP1/R1BQKBNR w KQkq - 0 5 -- here still okay
rnbqk1nR/ppp1ppb1/6p1/3p4/8/2N5/PPPPPPP1/R1BQKBN1 b Qkq - 0 5 -- here the rook gets taken but castling rights are preserved for black
rnbqk1nb/ppp1pp2/6p1/3p4/8/2N5/PPPPPPP1/R1BQKBN1 w Qkq - 0 6
rnbqk1nb/ppp1pp2/6p1/3p4/8/2N1P3/PPPP1PP1/R1BQKBN1 b Qkq - 0 6
rnbqk1nb/pp2pp2/6p1/2pp4/8/2N1P3/PPPP1PP1/R1BQKBN1 w Qkq c6 0 7
rnbqk1nb/pp2pp2/6p1/2pp4/8/2N1PN2/PPPP1PP1/R1BQKB2 b Qkq - 1 7
r1bqk1nb/pp2pp2/2n3p1/2pp4/8/2N1PN2/PPPP1PP1/R1BQKB2 w Qkq - 2 8
r1bqk1nb/pp2pp2/2n3p1/2pp4/3P4/2N1PN2/PPP2PP1/R1BQKB2 b Qkq d3 0 8
r2qk1nb/pp2pp2/2n3p1/2pp4/3P2b1/2N1PN2/PPP2PP1/R1BQKB2 w Qkq - 1 9
r2qk1nb/pp2pp2/2n3p1/1Bpp4/3P2b1/2N1PN2/PPP2PP1/R1BQK3 b Qkq - 2 9
r2qk1nb/pp2pp2/2n3p1/1B1p4/3p2b1/2N1PN2/PPP2PP1/R1BQK3 w Qkq - 0 10
r2qk1nb/pp2pp2/2n3p1/1B1p4/3P2b1/2N2N2/PPP2PP1/R1BQK3 b Qkq - 0 10
2rqk1nb/pp2pp2/2n3p1/1B1p4/3P2b1/2N2N2/PPP2PP1/R1BQK3 w Qk - 1 11
2rqk1nb/pp2pp2/2n3p1/1B1p4/3P2b1/2N1BN2/PPP2PP1/R2QK3 b Qk - 2 11
2rqk1nb/pp3p2/2n1p1p1/1B1p4/3P2b1/2N1BN2/PPP2PP1/R2QK3 w Qk - 0 12
2rqk1nb/pp3p2/2n1p1p1/1B1p4/3P2b1/2N1BN2/PPPQ1PP1/R3K3 b Qk - 1 12
2rqk1nb/pp3p2/2n1p1p1/1B1p4/3P4/2N1Bb2/PPPQ1PP1/R3K3 w Qk - 0 13
2rqk1nb/pp3p2/2n1p1p1/1B1p4/3P4/2N1BP2/PPPQ1P2/R3K3 b Qk - 0 13
2rqk1nb/1p3p2/p1n1p1p1/1B1p4/3P4/2N1BP2/PPPQ1P2/R3K3 w Qk - 0 14
2rqk1nb/1p3p2/p1B1p1p1/3p4/3P4/2N1BP2/PPPQ1P2/R3K3 b Qk - 0 14
3qk1nb/1p3p2/p1r1p1p1/3p4/3P4/2N1BP2/PPPQ1P2/R3K3 w Qk - 0 15 -- here stockfish 15.1 crashes

Feel free to mark the issue as closed

@Disservin Disservin closed this as not planned Won't fix, can't repro, duplicate, stale Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants