I have created a GUI that communicates with a Stockfish 8 engine by passing it a FEN string. Everything works nice but on some specific FEN strings, Stockfish crashes. I don't have any clue why...

One of the FEN strings on which Stockfish crashes is

r2k1b1r/pp4p1/4QnPp/3p1B1P/2pPp3/3qP2N/5PKR/3nB3 b KQkq - 0 1
  • 2
    I don't know whether this is the reason, but since both kings have moved already castling should not be allowed anymore for either side. "KQkq" should be "-" – user1583209 Jan 19 '18 at 10:06
  • Note that a program shouldn't crash on invalid input. It should return an error message or fail somehow, but not crash. – Federico Poloni Jan 19 '18 at 17:42
  • Following up on Federico's comment... Is this an interface that a regular user could send a FEN to or this is a programmer only interface and you are expected to check the validity of the FEN beforehand? Also, by crash, do you really mean "crash"? – user1583209 Jan 19 '18 at 20:33
  • @user1583209 developer only – SmallChess Jan 19 '18 at 23:43

Very simple, your FEN is absolutely invalid. You shouldn't give castling rights in a position that you kings have already moved. This won't work.

  • Ok i get it, but why it crashes on FEN where I have turned castling off for both sides E.g., it crashes on r4k2/3b1pp1/3bp1r1/1p1p4/pPpPnP1P/P1PqPN1N/6K1/R1B2Q1R b - - 0 1 – Mohd Waseem Jan 19 '18 at 11:37
  • @MohdWaseem Pls post that one in your question? – SmallChess Jan 19 '18 at 11:37
  • is anything wrong in FEN r4k2/3b1pp1/3bp1r1/1p1p4/pPpPnP1P/P1PqPN1N/6K1/R1B2Q1R b - - 0 1 – Mohd Waseem Jan 19 '18 at 11:47
  • @MohdWaseem Do you know how to play chess? Are you hired for a chess job that you know nothing about? – SmallChess Jan 19 '18 at 12:00
  • @MohdWaseem Do you know it's illegal to capture the king in check? I suggest you grab a chess book and learn the rules. You're wasting time unless you know the rules. – SmallChess Jan 19 '18 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.