Newbie C++ compiling question

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

tpetzke
Posts: 686
Joined: Thu Mar 03, 2011 4:57 pm
Location: Germany

Re: Newbie C++ compiling question

Post by tpetzke »

Hi Jacob,

as suggested already I also think it is an access to an array outside its boundaries. I encountered it 2-3 times and it always came down to this.

If you can run a ply 8 search is the node count exactly the same between debug and release, if not find the node where the difference occurs. In its vicinity the buggy code is triggered.

If up to ply 8 everything is equal, use another position to test or output some debug information at ply 9 to see how far the search still works.

So good luck
Thomas...
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Newbie C++ compiling question

Post by Sven »

You can also try to compile the release version with debug info still included, so that you can run your release version within the debugger, hoping that it will stop at the point of crash.

Sven
Richard Allbert
Posts: 792
Joined: Wed Jul 19, 2006 9:58 am

Re: Newbie C++ compiling question

Post by Richard Allbert »

This may be a stupid answer, but do you have any debug only code, such as asserts? It could be that something uninitialized / out of bounds is 'fixed' by debug mode only code. This has happened to me before.

Good luck

Richard
jacobbl
Posts: 80
Joined: Wed Feb 17, 2010 3:57 pm

Re: Newbie C++ compiling question

Post by jacobbl »

Hi, I just want to thank everyone for their help. After a long week with painful debugging it now seems to work :-)

Regards
Jacob
Sven
Posts: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

Re: Newbie C++ compiling question

Post by Sven »

jacobbl wrote:Hi, I just want to thank everyone for their help. After a long week with painful debugging it now seems to work :-)

Regards
Jacob
Nice to read that. But you write "it seems". Do you know what exactly had caused the trouble? Otherwise I would not consider it "solved", and it will most probably come back some day.

Sven
jacobbl
Posts: 80
Joined: Wed Feb 17, 2010 3:57 pm

Re: Newbie C++ compiling question

Post by jacobbl »

Yes, I found a bug that made a variable get a wrong value. This variable was used as an index in an array. I've now played 300 games without a single crash. So it looks good :-)
diep
Posts: 1822
Joined: Thu Mar 09, 2006 11:54 pm
Location: The Netherlands

Re: Newbie C++ compiling question

Post by diep »

jacobbl wrote:Yes, I found a bug that made a variable get a wrong value. This variable was used as an index in an array. I've now played 300 games without a single crash. So it looks good :-)
thumbs up!

p.s. now let's hope it doesn't beat tomorrow already rybka 1.0
User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Newbie C++ compiling question

Post by lucasart »

jacobbl wrote:Yes, I found a bug that made a variable get a wrong value. This variable was used as an index in an array. I've now played 300 games without a single crash. So it looks good :-)
Good news :D

But to prevent this kind of problem in the future, I strongly recommend that you encapsulate as much as possible intpo fuinctions (like accessors) with assert checks at the entry of each function.

I've got assert everywhere in my code, and things that get computed twice in different ways to double check their correctness with an assert statement. It saved my life **so** many times, you can't imagine...