On-line engine blitz tourney July

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: On-line engine blitz tourney July

Post by hgm »

Just to avoid any confusion: I have decided that in any case there will not be a tourney today.
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: On-line engine blitz tourney July

Post 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?
User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: On-line engine blitz tourney July

Post 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.
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: On-line engine blitz tourney July

Post 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.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: On-line engine blitz tourney July

Post 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.
Rasmus Althoff
https://www.ct800.net
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: On-line engine blitz tourney July

Post 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.
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: On-line engine blitz tourney July

Post 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.
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: On-line engine blitz tourney July

Post 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?
User avatar
hgm
Posts: 27788
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: On-line engine blitz tourney July

Post 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.
Joost Buijs
Posts: 1563
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: On-line engine blitz tourney July

Post by Joost Buijs »

hgm wrote: Sat Sep 28, 2019 4: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.