Bugs / IO / longjmp

Everything what does not fit in the other forums. Chess related or not, trivial or sophisticated, but keep it civilized and respect others please.

Moderator: Andres Valverde

Bugs / IO / longjmp

Postby BitSet » 13 Dec 2010, 17:43

Hi,
I have some very difficult to find bug in my engine which IMO decreases playing strength and also sometimes manifests itself in XBoard engine output window. Sometimes some of output lines contain only depth and PV, score, node count and time are missing. How is this possible? I mean what engine output can cause such XBoard behaviour? Can -O1 break code? I use -O3 but -O1 doesn't seem to solve the problem.
Last edited by BitSet on 18 Dec 2010, 18:52, edited 1 time in total.
BitSet
 
Posts: 23
Joined: 27 Feb 2010, 16:25

Re: XBoard engine output

Postby Dann Corbit » 13 Dec 2010, 22:00

Can you post your I/O code?
Do you have buffering turned off via setbuf or setvbuf?
Dann Corbit
 

Re: XBoard engine output

Postby BitSet » 13 Dec 2010, 23:30

I use
Code: Select all
cout.setf(ios::unitbuf);
for cout and nothing for cin. I don't know if it's somehow connected to my problem because score, nod count and time are between depth and PV but depth and PV are always printed. The case when only depth and PV are displayed is VERY rare and I think it may be caused by some overwrite in memory. I compiled my engine with -fstack-protector and applied PaX policy -PMRXSe but I didn't manage to crash it anyway :( That's the reason why I asked what engine output causes XBoard to omit everything between depth and PV. My engine always sends: depth, score, nod count, time and PV - it's all in one cout line.
BitSet
 
Posts: 23
Joined: 27 Feb 2010, 16:25

Re: XBoard engine output

Postby Dann Corbit » 15 Dec 2010, 03:03

BitSet wrote:I use
Code: Select all
cout.setf(ios::unitbuf);
for cout and nothing for cin. I don't know if it's somehow connected to my problem because score, nod count and time are between depth and PV but depth and PV are always printed. The case when only depth and PV are displayed is VERY rare and I think it may be caused by some overwrite in memory. I compiled my engine with -fstack-protector and applied PaX policy -PMRXSe but I didn't manage to crash it anyway :( That's the reason why I asked what engine output causes XBoard to omit everything between depth and PV. My engine always sends: depth, score, nod count, time and PV - it's all in one cout line.



I suggest you turn off buffering both ways (I usually use this for C++):

Code: Select all
cout.rdbuf()->pubsetbuf(NULL,0);
cin.rdbuf()->pubsetbuf(NULL,0);


Also, this forum is not the one that you want. Try the programming forums.
Dann Corbit
 

Re: XBoard engine output

Postby BitSet » 15 Dec 2010, 17:17

Thanks for tried solution!

Anyway the problem doesn't seem to be solveable. I changed code in the way search at current ply is aborted if time is over. My engine in some positons stucks in infinit loop of aspiration search at depth==1 (first search). It's because alpha==-INT_MAX && beta==INT_MAX and returned score==INT_MAX, so loop is never left because window cannot be wider but also INT_MAX or -INT_MAX can be returned only when search has already been aborted due to time limit hit, in such case result is simply ignored. Search isn't aborted but INT_MAX is returned. It cannot be explained.
BitSet
 
Posts: 23
Joined: 27 Feb 2010, 16:25

Re: XBoard engine output

Postby Dann Corbit » 15 Dec 2010, 20:26

BitSet wrote:Thanks for tried solution!

Anyway the problem doesn't seem to be solveable. I changed code in the way search at current ply is aborted if time is over. My engine in some positons stucks in infinit loop of aspiration search at depth==1 (first search). It's because alpha==-INT_MAX && beta==INT_MAX and returned score==INT_MAX, so loop is never left because window cannot be wider but also INT_MAX or -INT_MAX can be returned only when search has already been aborted due to time limit hit, in such case result is simply ignored. Search isn't aborted but INT_MAX is returned. It cannot be explained.



Everything has an explanation, and all problems are solveable.

Is your engine open source so that others can examine it?
Dann Corbit
 

Re: XBoard engine output

Postby BitSet » 18 Dec 2010, 00:15

Infinite loop was caused by TT cutoff with score of INT_MAX. This score was saved in TT because when I removed longjmp, search wasn't aborted instantly but gradually, returning -INT_MAX and this was saved to TT despite the fact that search has already been aborted. That's how impossible becomes possible! Problem described in first post may be caused by longjmp but I'm not sure, longjmp isn't rather safe thing to use in C++ even if I use it before any objects with destructors that need to be called because I can't guess how code will look like after -O3.
BitSet
 
Posts: 23
Joined: 27 Feb 2010, 16:25


Return to Anything else

Who is online

Users browsing this forum: No registered users and 2 guests