Page 6 of 7

Re: On-line engine blitz tourney July

Posted: Sat Aug 31, 2019 3:42 pm
by hgm
Just to avoid any confusion: I have decided that in any case there will not be a tourney today.

Re: On-line engine blitz tourney July

Posted: Sun Sep 22, 2019 11:52 am
by Joost Buijs
Some time ago I setup a test server with the latest Capablanca source but I never used it, this weekend I tried to revive it and I had difficulties getting mamer to recognize commands.

After some debugging I found the culprit in Mamer::HandleTell() at line 807

The following code fails with GCC (assuming i == 0):

Code: Select all

    while((command[i] != '\0') && (command[i] != ' ')) tmpCom[i] = command[i++];
    tmpCom[i] = '\0';
However the following code works:

Code: Select all

    while((command[i] != '\0') && (command[i] != ' '))
    {
       tmpCom[i] = command[i];
       i++;
    }
    tmpCom[i] = '\0';
I don't know what the C++ standard has to say about this, but to me it looks like a compiler bug. Of course this is very ugly code, if you look at the whole source you may call it a wonder that it actually works, but still.

BTW is there any news with regard to the latest crashes of the server?, or did the tourney die a slow death?

Re: On-line engine blitz tourney July

Posted: Sun Sep 22, 2019 12:14 pm
by xr_a_y
before c++17, the right hand side of such an operator was undetermined I guess.
I think another famous example is

Code: Select all

void f(int k, int j){
   std::cout << k << std::endl;
   std::cout << j << std::endl;
}
int i = 0;
f(i,i++); // undefined behaviour
See https://en.cppreference.com/w/cpp/language/eval_order for more details.

Re: On-line engine blitz tourney July

Posted: Sun Sep 22, 2019 12:30 pm
by Joost Buijs
Probably not a bug than. I'm used to ICC and MSVC, these compilers already do for ages what you expect of such a statement, maybe it is different with GCC, with older versions of GCC this code didn't give any problems. The point is that the whole server code is literally filled with stuff like this, there is a big change that there will be other hidden bugs.

Re: On-line engine blitz tourney July

Posted: Sun Sep 22, 2019 1:41 pm
by Ras
That should be undefined behaviour, and it has always been. Especially the GCC team is well-known to have taken an ever more aggressive stance towards undefined behaviour. If the code is broken, then each GCC update will increase the odds of actually manifesting the code issues.

Re: On-line engine blitz tourney July

Posted: Sun Sep 22, 2019 2:23 pm
by Joost Buijs
Most compilers I know have no problem with:

Code: Select all

 while ((s1[i] = s2[i++]) != 0); 
I guess the original author(s) of the server software thought this too. Personally I never use constructs like this because it decreases readability.

Re: On-line engine blitz tourney July

Posted: Sat Sep 28, 2019 8:41 am
by Joost Buijs
I tried to make my local server crash by throwing very long PV strings with a lot of garbage at it, but the only thing that crashed (or aborted) was polyglot because it has an input buffer size of 4096 bytes. It is possible that polyglot filters a lot of unwanted crap, when the engine is connected via icsdrone things could be different, unfortunately I'm not able to try that because I run under Windows.

I noticed that the server crashes when I add a new player without setting a password (the 'addplayer' command does not seem to set a default password), when the new player logs in the server immediately crashes.

The server is reachable at 'nightmare-chess.nl' port 5000, I setup sendmail as well, so 'mailoldmoves' and 'mailstored' should work. It is running on a tiny computer, I have no idea about how many concurrent users it can handle.

Re: On-line engine blitz tourney July

Posted: Sat Sep 28, 2019 1:12 pm
by Joost Buijs
When I look at the source I see that 'addplayer' at default adds a 4 character password, so I is not very clear to me what went wrong, it only happened once, but it is still something to look at.

Something else that puzzles me is how to add computer players (with a (C) after their handle), according to the manual it should be possible, but I can't find anywhere how to do it. Maybe HGM knows?

Re: On-line engine blitz tourney July

Posted: Sat Sep 28, 2019 2:11 pm
by hgm
The ICS maintains 'lists', and has a command that adds an item to a list. I always use the predefined alias '+' for this command. So "+computer Nightmare" would add Nightmare to the 'computer' list. And this list is used to add the (C) to printed player names. I don't remember whether the computer list is automatically created when you add something to it, or whether there is a separate command to create lists that has to be used first.

Re: On-line engine blitz tourney July

Posted: Sat Sep 28, 2019 2:54 pm
by Joost Buijs
hgm wrote:
Sat Sep 28, 2019 2:11 pm
The ICS maintains 'lists', and has a command that adds an item to a list. I always use the predefined alias '+' for this command. So "+computer Nightmare" would add Nightmare to the 'computer' list. And this list is used to add the (C) to printed player names. I don't remember whether the computer list is automatically created when you add something to it, or whether there is a separate command to create lists that has to be used first.
Thanks! This leads me in the right direction.

The ICS is fully functional now, I've added chessd, mamer and a script to spool the emails as .service to etc/systemd, it all seems to work, only mamer does not automatically reconnect when it has lost connection to the server, I still have to look at this.