Page 1 of 1

[Solved] My UCI only works if called directly

PostPosted: 08 Jul 2018, 20:38
by purefan
Hello!

I've come up with a bridge, its a really simple program that connects to a real UCI engine. If I call my program from the console it takes input through stdin and I can speak UCI to it, it then relays the commands to the real UCI engine and outputs to stdout whatever the UCI engine says. I have tried to load my program (lets call it fakeUCI) into Arena and Scid and it just doesn't work, I added some logging and am certain that fakeUCI is not being loaded, but have no clue why since when I run it myself it does work.

I know this is pretty vague but maybe someone has run into something like this and can shed some light?

Thanks!

Re: My UCI only works if called directly

PostPosted: 10 Jul 2018, 02:30
by H.G.Muller
Hard to say, when you don't even mention if this is under Windows, Linux or Mac. The most common reason why things work differently under Windows when run from the console or from a GUI (i.e. through a pipe) is that they use the wrong call when peeking for input (which in Windows needs to be different for the two cases). Best approach is to debug by splattering the entire program with print statements to the log file (and be sure to flush them), so you can be sure of exactly what it does (and thus of what it does wrong).

Re: My UCI only works if called directly

PostPosted: 21 Jul 2018, 15:14
by purefan
Hi Muller,

I've been trying to debug this even further without any success. Im working under linux and adding logs didn't help, the very first instruction is "write to this log file", if I run my program directly from terminal the file does get populated fine, if I load it on Scid I only get the error message (within Scid) and the file does not get the line appended.

I downloaded Scid and found the error phrase, it's in this block of code:
Code: Select all
        if { $exit_status != 0 } {
            logEngineNote $n {Engine terminated with exit code $exit_status: "\"$standard_error\""}
            tk_messageBox -type ok -icon info -parent . -title "Scid" \
                          -message "The analysis engine terminated with exit code $exit_status: \"$standard_error\""
        } else {
            logEngineNote $n {Engine terminated without exit code: "\"$standard_error\""}
            tk_messageBox -type ok -icon info -parent . -title "Scid" \
                          -message "The analysis engine terminated without exit code: \"$standard_error\""
        }


(Theres a similar string but the other one has a typo exit != exist)
This is in tcl/tools/analysis.tcl:2304

I'm afraid not experienced enough to debug this further within scid (to figure out why is my binary failing to load)

Re: My UCI only works if called directly

PostPosted: 21 Jul 2018, 17:54
by purefan
In another try I loaded my program into Arena for linux and it does trigger the first line of debugging (it does get appended to my log file), nothing further after that but the behavior is at least different

Re: My UCI only works if called directly

PostPosted: 21 Jul 2018, 18:30
by purefan
And a bit more progress with Arena for linux, I was able to debug (by appending to a file) that all the declarations seem ok, I suspect the problem is when reading from stdin because that event doesn't fire (or doesn't log at least)

Re: My UCI only works if called directly

PostPosted: 02 Aug 2018, 19:13
by H.G.Muller
Are you flushing the debug output every time you print some? If it would get buffered you would not see it.

Re: My UCI only works if called directly

PostPosted: 03 Aug 2018, 08:39
by purefan
Thanks for the follow up H.G.Muller

I came to the conclusion that it was a compiler error, the websockets libraries behave different when compiled, I switched to long polling and it is working now, I have no clue yet why it worked better in Arena than in Scid but it seems to be working now, it even worked on chessbase so I guess its safe to close this thread.

Thanks again!