The recent removal of piece lists might have fixed that (it seems to work for me).RubiChess wrote: ↑Fri Dec 11, 2020 9:22 am What do you think about this kind of position?
KQQQQQQQ/QQQQQQQQ/QQQQQQQQ/QQQqqqqq/QQQqqqqq/QQQqqqqq/QQQqqqqq/QQQqqqqk b - - 1 1
GUIs might (and do) accept this as a "puzzle" position although it is not legal in terms of reachable from the start position. Which is totally okay in my opinion.
Stockfish crashes on it.
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: 2487
- Joined: Tue Aug 30, 2016 8:19 pm
- Full name: Rasmus Althoff
Re: Position Causes Stockfish and Komodo To Crash
Of course it can. My engine does this.
Rasmus Althoff
https://www.ct800.net
https://www.ct800.net
-
- Posts: 1754
- Joined: Tue Apr 19, 2016 6:08 am
- Location: U.S.A
- Full name: Andrew Grant
Re: Position Causes Stockfish and Komodo To Crash
You are lazy for not giving me good inputs? Its not lazy, its simply not important.Dann Corbit wrote: ↑Fri Dec 11, 2020 6:06 pmIs that how you would write code for a customer? Unexpected input causes a program crash?AndrewGrant wrote: ↑Fri Dec 11, 2020 8:14 am Someone recently wasted their time writing up 20 paragraphs showing how they could "exploit" Stockfish into crashing....
If you send a chess engine garbage, you should expect garbage. If you don't know it is garbage, then maybe a GUI should be doing it for you.
The above has been affirmed many times in Stockfish PRs, where users come saying they have found a "bug"
If a programmer is too lazy even to think hard, they can still use try catch (yes, I know, a 1% performance penalty).
It boggles my mind how chess programmers will spend 10,000 hours writing their programs but spend zero minutes checking the input for correctness.
Some engines don't even parse the entire FEN. Now that is lazy.
#WeAreAllDraude #JusticeForDraude #RememberDraude #LeptirBigUltra
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
"Those who can't do, clone instead" - Eduard ( A real life friend, not this forum's Eduard )
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Position Causes Stockfish and Komodo To Crash
Your engine reports it to the user, not to the GUI. The GUI will likely get terribly confused if it does not crash.
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Position Causes Stockfish and Komodo To Crash
Does your engine also refuse to crash or freeze if you change the TT size or the number of search threads halfway through a search?
The whole point of the UCI protocol is that it allows an engine not to bother with a whole lot of stuff that is better left to the GUI.
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Position Causes Stockfish and Komodo To Crash
Not doing more than what the spec requires is the right form of laziness. A customer should not need to pay for fancy and unnecessary stuff going beyond the spec.Dann Corbit wrote: ↑Fri Dec 11, 2020 6:06 pmIs that how you would write code for a customer? Unexpected input causes a program crash?AndrewGrant wrote: ↑Fri Dec 11, 2020 8:14 am Someone recently wasted their time writing up 20 paragraphs showing how they could "exploit" Stockfish into crashing....
If you send a chess engine garbage, you should expect garbage. If you don't know it is garbage, then maybe a GUI should be doing it for you.
The above has been affirmed many times in Stockfish PRs, where users come saying they have found a "bug"
If a programmer is too lazy even to think hard, they can still use try catch (yes, I know, a 1% performance penalty).
It boggles my mind how chess programmers will spend 10,000 hours writing their programs but spend zero minutes checking the input for correctness.
The UCI spec requires the GUI to give the engine sane inputs. Therefore the engine should expect sane inputs.
(Admittedly the UCI spec is very mistaken where it requires an engine to ignore unrecognised tokens but to do its best to process the rest of the input line. I'm not convinced that many engines will "correctly" process "gobbledygook go infinite".)
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Position Causes Stockfish and Komodo To Crash
https://pubs.opengroup.org/onlinepubs/0 ... /free.html
How many here take the view that a C library that claims to be POSIX-compliant but that crashes when free() is called twice on the same pointer is "pathetic"/"never OK"/etc?The free() function shall cause the space pointed to by ptr to be deallocated; that is, made available for further allocation. If ptr is a null pointer, no action shall occur. Otherwise, if the argument does not match a pointer earlier returned by the calloc(), malloc(), posix_memalign(), realloc(), or strdup() function, or if the space has been deallocated by a call to free() or realloc(), the behavior is undefined.
Any use of a pointer that refers to freed space results in undefined behavior.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Position Causes Stockfish and Komodo To Crash
is crashing or freezing the right thing to do though? my engine simply aborts the search in this case, I really don't like crashes in general.
as for double free - a dangling pointer is the responsibility of the programmer, not the C library.
I don't see how this analogy is relevant here.
I certainly wouldn't like my text editor to crash on bad regex pattern, which is a better example I think.
Martin Sedlak
-
- Posts: 5566
- Joined: Tue Feb 28, 2012 11:56 pm
Re: Position Causes Stockfish and Komodo To Crash
Des your engine catch all such cases? Is your GUI thread aware of all the possible invalid input sequences that a malicious GUI could send it? It seems a lot of work to get 100% right.
Exactly.as for double free - a dangling pointer is the responsibility of the programmer, not the C library.
It is the GUI author's responsibility to give the UCI engine valid input.I don't see how this analogy is relevant here.
I certainly wouldn't like my chess GUI to crash on an illegal position set up by the user.I certainly wouldn't like my text editor to crash on bad regex pattern, which is a better example I think.
-
- Posts: 2555
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Position Causes Stockfish and Komodo To Crash
most likely not, it's hard to cover 100% of the cases and all code paths. but at least I try to handle the obvious ones.
I agree, but some people run engines from the command line. I certainly use command line when debugging my engine.It is the GUI author's responsibility to give the UCI engine valid input.
Martin Sedlak