Illegal positions: Note that either setboard or edit can be used to send an illegal position to the engine. The user can create any position with xboard's Edit Position command (even, say, an empty board, or a board with 64 white kings and no black ones). If your engine receives a position that it considers illegal, I suggest that you send the response "tellusererror Illegal position", and then respond to any attempted move with "Illegal move" until the next new, edit, or setboard command.
Variant capable interfaces like XBoard are quite lenient on what they allow on the board. Engine however should not process such positions. Besides lack of both kings, one thing that would definitely prevent normal engine play would be the presence of pawns on either 1st or 8th rank, so reject such positions too.
Couple of FENS that will be considered illegal, with pawn on 1st / 8th rank:
From: https://www.gnu.org/software/xboard/engine-intf.html
Variant capable interfaces like XBoard are quite lenient on what they allow on the board. Engine however should not process such positions. Besides lack of both kings, one thing that would definitely prevent normal engine play would be the presence of pawns on either 1st or 8th rank, so reject such positions too.
Couple of FENS that will be considered illegal, with pawn on 1st / 8th rank: