Answers.Body: <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-19T11:37:12.197Z
Answers.Text: 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
Answers.UserDisplayName: Mohd Waseem
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-19T11:37:55.943Z
Answers.Text: @MohdWaseem Pls post that one in your question?
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-19T11:47:52.533Z
Answers.Text: is anything wrong in FEN r4k2/3b1pp1/3bp1r1/1p1p4/pPpPnP1P/P1PqPN1N/6K1/R1B2Q1R b - - 0 1
Answers.UserDisplayName: Mohd Waseem
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-19T12:00:59.603Z
Answers.Text: @MohdWaseem Do you know how to play chess? Are you hired for a chess job that you know nothing about?
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-19T12:01:52.160Z
Answers.Text: @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.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-19T12:04:31.310Z
Answers.Text: @MohdWaseem https://en.wikipedia.org/wiki/Rules_of_chess Study the chess rules. Learn it.
Answers.UserDisplayName: SmallChess
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-19T11:03:58.820Z
Answers.LastActivityDate: 2018-01-19T11:03:58.820Z
Answers.UserDisplayName: SmallChess
Body: <p>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...</p>
  
  <p>One of the FEN strings on which Stockfish crashes is</p>
  
  <pre><code>r2k1b1r/pp4p1/4QnPp/3p1B1P/2pPp3/3qP2N/5PKR/3nB3 b KQkq - 0 1
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-19T10:06:03.570Z
Comments.Text: 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 "-"
Comments.UserDisplayName: user1583209
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-19T17:42:34.230Z
Comments.Text: Note that a program shouldn't crash on invalid input. It should return an error message or fail somehow, but not crash.
Comments.UserDisplayName: Federico Poloni
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-19T20:33:46.303Z
Comments.Text: 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"?
Comments.UserDisplayName: user1583209
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-19T23:43:52.277Z
Comments.Text: @user1583209 developer only
Comments.UserDisplayName: SmallChess
Tags: <stockfish>
Title: Stockfish crashes on fen string
ThreadText: # Stockfish crashes on fen string
  
  (Asked by: username_0 on 2018-01-19)
  
  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
  
  ```
  
  **Tags:** stockfish
  
  > **Comments:**
  > **username_1**: 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 "-"  
  > **username_2**: Note that a program shouldn't crash on invalid input. It should return an error message or fail somehow, but not crash.  
  > **username_1**: Following up on username_2'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"?  
  > **username_3**: @username_1 developer only  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2018-01-19. Score: 2
  
  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.
  
  > **Comments:**
  > **username_0**: 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  
  > **username_3**: @username_0 Pls post that one in your question?  
  > **username_0**: is anything wrong in FEN r4k2/3b1pp1/3bp1r1/1p1p4/pPpPnP1P/P1PqPN1N/6K1/R1B2Q1R b - - 0 1  
  > **username_3**: @username_0 Do you know how to play chess? Are you hired for a chess job that you know nothing about?  
  > **username_3**: @username_0 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.  
  > **username_3**: @username_0 https://en.wikipedia.org/wiki/Rules_of_chess Study the chess rules. Learn it.  
  
  ---
  
  