Frontend as in the browser? That wouldn't be particularly safe.
Position Causes Stockfish and Komodo To Crash
Moderators: hgm, Rebel, chrisw
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Position Causes Stockfish and Komodo To Crash
-
- Posts: 395
- Joined: Fri Aug 12, 2016 8:43 pm
Re: Position Causes Stockfish and Komodo To Crash
It also depends on the language you can/want use.Sesse wrote: ↑Sat Dec 19, 2020 2:37 pm It also appears to be rudimentary, e.g. doesn't test if both sides are in check:
https://github.com/ornicar/scalachess/b ... scala#L172
c++ isn't so good for internet development, but I can point you to the SCID's code:
https://github.com/benini/scid/blob/git ... .cpp#L2665
https://github.com/benini/scid/blob/git ... n.cpp#L270
which can be used like:
Code: Select all
#include <cstdio>
#include "position.h"
int main() {
auto fen = "nbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR K KQkq - 0 1";
if (Position().ReadFromFEN(fen) != OK) {
std::printf("invalid");
}
}
-
- Posts: 395
- Joined: Fri Aug 12, 2016 8:43 pm
Re: Position Causes Stockfish and Komodo To Crash
Your question has been answered many times: Stockfish requires valid input, otherwise it's behavior is undefined.
I can post another link to this very simple concept, that when you design something you also state the prerequisites necessary for it to work:
https://blog.llvm.org/posts/2011-05-13- ... ould-know/
but you will not be able to understand it, because you do not want to.
crash is evil, nothing should ever crash...
yes, but sometimes it is acceptable if you trust...
no, no, you're trying to taint my soul!!
not at all, we can trust our fellow citizens and build walls just around the city...
you are the devil! I want the highest wall around my house, better my room, and I will never let anything in without checking it ten million times...
-
- Posts: 2272
- Joined: Mon Sep 29, 2008 1:50 am
Re: Position Causes Stockfish and Komodo To Crash
You still haven't answered my question... Again: do you think it would be ok for ld to crash when encountering an unknown file format?Fulvio wrote: ↑Sat Dec 19, 2020 3:53 pmYour question has been answered many times: Stockfish requires valid input, otherwise it's behavior is undefined.
I can post another link to this very simple concept, that when you design something you also state the prerequisites necessary for it to work:
https://blog.llvm.org/posts/2011-05-13- ... ould-know/
but you will not be able to understand it, because you do not want to.
crash is evil, nothing should ever crash...
yes, but sometimes it is acceptable if you trust...
no, no, you're trying to taint my soul!!
not at all, we can trust our fellow citizens and build walls just around the city...
you are the devil! I want the highest wall around my house, better my room, and I will never let anything in without checking it ten million times...
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
Without ideas there is nothing to simplify.
-
- Posts: 300
- Joined: Mon Apr 30, 2018 11:51 pm
-
- Posts: 300
- Joined: Mon Apr 30, 2018 11:51 pm
Re: Position Causes Stockfish and Komodo To Crash
That doesn't test semantics either, e.g. side not to move is not in check. Just like Lichess' code.Fulvio wrote: ↑Sat Dec 19, 2020 3:36 pm It also depends on the language you can/want use.
c++ isn't so good for internet development, but I can point you to the SCID's code:
https://github.com/benini/scid/blob/git ... .cpp#L2665
https://github.com/benini/scid/blob/git ... n.cpp#L270
-
- Posts: 395
- Joined: Fri Aug 12, 2016 8:43 pm
Re: Position Causes Stockfish and Komodo To Crash
I think it does, if you look at the last FEN in the tests I already posted:Sesse wrote: ↑Sat Dec 19, 2020 4:47 pmThat doesn't test semantics either, e.g. side not to move is not in check. Just like Lichess' code.Fulvio wrote: ↑Sat Dec 19, 2020 3:36 pm It also depends on the language you can/want use.
c++ isn't so good for internet development, but I can point you to the SCID's code:
https://github.com/benini/scid/blob/git ... .cpp#L2665
https://github.com/benini/scid/blob/git ... n.cpp#L270
https://github.com/benini/scid/blob/git ... n.cpp#L295
-
- Posts: 300
- Joined: Mon Apr 30, 2018 11:51 pm
Re: Position Causes Stockfish and Komodo To Crash
OK, fine, but it doesn't have any double-check tests; e.g., it accepts rnbqkbnr/ppppppN1/3N1N2/8/8/8/PPPPPPP1/R1BQKB1R b - - 0 1 (a triple-check).
-
- Posts: 395
- Joined: Fri Aug 12, 2016 8:43 pm
Re: Position Causes Stockfish and Komodo To Crash
That's mate and it is also considered valid by Stockfish.
This is what it is considered invalid (plus max 16 pieces for each side):
https://github.com/benini/scid/blob/git ... .cpp#L1580
If you want to exclude positions that cannot be reached in a normal game that would be trickier.
Are you aware of any position of that type that cause problems with Stockfish?
-
- Posts: 2272
- Joined: Mon Sep 29, 2008 1:50 am
Re: Position Causes Stockfish and Komodo To Crash
I doubt that SF would have issues handling triple checks. Such a position is only illegal in the sense that it has no ancestor.
Of course this is also a mate position and it is debatable if the GUI is allowed to make a UCI engine search a mate position.
Ideas=science. Simplification=engineering.
Without ideas there is nothing to simplify.
Without ideas there is nothing to simplify.