ddugovic / Stockfish

Retired multi-variant fork of popular UCI chess engine; please use Fairy-Stockfish instead
https://github.com/ianfab/Fairy-Stockfish
GNU General Public License v3.0
132 stars 44 forks source link

Segmentation fault when set Skill level and non-interactive #395

Closed esteveste closed 7 years ago

esteveste commented 7 years ago
printf 'uci
setoption name Skill Level value 10
go movetime 3000
go
' | ./stockfish
.........
ll 924 tbhits 0 time 3004 pv e2e4 e7e5 g1f3 b8c6 d2d4 e5d4 f3d4 d7d5 d4c6 b7c6 e4d5 d8d5 d1e2 d5e6 b1c3 f8d6 c3e4 g8e7 e4d6 e6d6 e2e4 d6e6 e4e6 c8e6
bestmove d2d4 ponder d7d5
Segmentation fault (core dumped)

This segmentation fault only occurs when I set the difficulty to a level lower than 20.

Another interesting point is that using this method i need to give 2 go's for it to assume the arguments of the first one. The same error occurs when I only put 1 go.

In an interactive way it works fine.

ddugovic commented 7 years ago

The following works on my computer. What's the OS/ARCH ?

$ cat test.txt - | ./stockfish
Stockfish 180817 64 BMI2 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
id name Stockfish 180817 64 BMI2
id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott

option name Debug Log File type string default
option name Contempt type spin default 0 min -100 max 100
option name Threads type spin default 1 min 1 max 512
option name Hash type spin default 16 min 1 max 1048576
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 500
option name Skill Level type spin default 20 min 0 max 20
option name Move Overhead type spin default 30 min 0 max 5000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_Chess960 type check default false
option name UCI_Variant type combo default chess var chess var giveaway var atomic var crazyhouse var horde var kingofthehill var losers var racingkings var 3check var suicide var bughouse var loop
option name SyzygyPath type string default <empty>
option name SyzygyProbeDepth type spin default 1 min 1 max 100
option name Syzygy50MoveRule type check default true
option name SyzygyProbeLimit type spin default 6 min 0 max 6
uciok
info depth 1 seldepth 1 multipv 1 score cp 93 nodes 74 nps 74000 tbhits 0 time 1 pv e2e4
info depth 2 seldepth 2 multipv 1 score cp 91 nodes 175 nps 87500 tbhits 0 time 2 pv e2e4 b7b6
info depth 3 seldepth 3 multipv 1 score cp 185 nodes 356 nps 178000 tbhits 0 time 2 pv e2e4 c7c6 d2d4
info depth 4 seldepth 4 multipv 1 score cp 114 nodes 1207 nps 402333 tbhits 0 time 3 pv e2e4 e7e6 d2d4 b7b6
info depth 5 seldepth 5 multipv 1 score cp 48 nodes 2498 nps 624500 tbhits 0 time 4 pv d2d4 d7d5 d1d3 e7e6 e2e4
info depth 6 seldepth 6 multipv 1 score cp 48 nodes 5018 nps 836333 tbhits 0 time 6 pv e2e4 d7d5 d1f3 e7e6 d2d4 d5e4 f3e4
info depth 7 seldepth 7 multipv 1 score cp 40 nodes 9925 nps 992500 tbhits 0 time 10 pv g1f3 d7d5 d2d4 b8c6 e2e3 e7e6 b1c3
info depth 8 seldepth 8 multipv 1 score cp 1 nodes 19209 nps 1129941 tbhits 0 time 17 pv e2e4 d7d5 e4e5 d5d4 d2d3 b8c6 g1f3 e7e6
info depth 9 seldepth 14 multipv 1 score cp 25 nodes 45413 nps 1164435 tbhits 0 time 39 pv e2e4 d7d5 e4d5 d8d5 b1c3 d5e6 d1e2 b8c6 e2e6 c8e6
info depth 10 seldepth 14 multipv 1 score cp 68 nodes 96126 nps 1172268 tbhits 0 time 82 pv e2e4 e7e6 b1c3 b8c6 d2d4 f8b4 g1f3 b4c3 b2c3 d7d5
info depth 11 seldepth 16 multipv 1 score cp 33 nodes 184034 nps 1179705 tbhits 0 time 156 pv e2e4 d7d5 e4d5 d8d5 b1c3 d5e6 g1e2 c7c5 d2d3 g8f6 d3d4 b8c6 d4c5
info depth 12 seldepth 19 multipv 1 score cp 50 nodes 283008 nps 1184133 tbhits 0 time 239 pv e2e4 e7e6 d2d4 d7d5 b1c3 d5e4 c3e4 b8c6 c2c3 d8d5 d1e2 g8e7
info depth 13 seldepth 21 multipv 1 score cp 45 nodes 594296 nps 1160734 tbhits 0 time 512 pv e2e4 e7e6 d2d4 d7d5 b1c3 b8c6 e4e5 f8b4 g1f3 g8e7 f1e2 b4c3 b2c3
info depth 14 seldepth 18 multipv 1 score cp 40 nodes 778803 nps 1155494 tbhits 0 time 674 pv e2e4 e7e5 d2d4 e5d4 d1d4 b8c6 d4e3 b7b6 b1c3 c8b7 g1f3 f8c5 e3d2 g8e7 c3d5 e7d5
info depth 15 seldepth 23 multipv 1 score cp 22 nodes 1635725 nps 1121896 hashfull 641 tbhits 0 time 1458 pv g1f3 d7d5 e2e3 e7e6 c2c4 g8f6 d2d4 c7c5 b1c3 b8c6 c4d5 f6d5 f1b5 c5d4 f3d4 c8d7 e1g1 d5c3
info depth 16 seldepth 23 multipv 1 score cp 45 nodes 2357368 nps 1111441 hashfull 809 tbhits 0 time 2121 pv e2e4 e7e5 g1f3 b8c6 f1b5 a7a6 b5c6 d7c6 e1g1 c8g4 d2d3 g4f3 d1f3 g8f6 b1c3 f8d6 c1g5 e8g8 g5f6 d8f6 f3f6
info depth 17 seldepth 29 multipv 1 score cp 26 nodes 3195052 nps 1099845 hashfull 920 tbhits 0 time 2905 pv e2e4 e7e5 g1f3 b8c6 d2d4 e5d4 f3d4 d7d5 d4c6 b7c6 e4d5 d8d5 d1e2 d5e6 b1c3 f8d6 c3e4 g8e7 e4d6 e6d6 e2e4 d6e6 e4e6 c8e6
info depth 18 seldepth 29 multipv 1 score cp 26 nodes 3303397 nps 1099300 hashfull 929 tbhits 0 time 3005 pv e2e4 e7e5 g1f3 b8c6 d2d4 e5d4 f3d4 d7d5 d4c6 b7c6 e4d5 d8d5 d1e2 d5e6 b1c3 f8d6 c3e4 g8e7 e4d6 e6d6 e2e4 d6e6 e4e6 c8e6
bestmove e2e4 ponder e7e5
ddugovic commented 7 years ago

Oh, I see what you're pointing out... that this non-interactive use case:

printf 'uci
go movetime 3000
' | ./stockfish

does not segfault, but your non-interactive use case does segfault. I'll have to test this upstream...

ddugovic commented 7 years ago

@official-stockfish Stockfish also segfaults. Here is the best explanation I could find why: https://chess.stackexchange.com/questions/14226/why-am-i-getting-different-behaviour-between-using-stockfish-as-a-child-node-pro

namely: Stockfish assumes the standard input/output works, always works.