Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Thanks Felipe Bergo!

Author: Miguel A. Ballicora

Date: 12:12:43 07/12/01

Go up one level in this thread


On July 12, 2001 at 13:51:11, Gian-Carlo Pascutto wrote:

>
>Felipe Bergo found out what was wrong:
>
>Sjeng allocated space for 300 moves, but in crazyhouse
>it is possible to have more possible moves than that!
>
>This was a big surprised to me, as I just picked 300 as
>a number-thats-certainly-big-enough.
>
>Looks like I was wrong.
>
>I still have no idea how to debug this kind of stack-trashing-bugs,
>but this one is squashed for sure :)
>
>--
>GCP

Hi Giancarlo,

Have you read "Writing Solid Code" by Steve Maguire? Some people criticized
this book and some loved it. I think that the controversy is for academic
reasons, but I really recommend it. You do not have to apply everything that is
in the book but it really opens your mind about how to deal with bugs. I do not
have a formal education in computer science, at least to me it helped me a lot.
One of the golden rules of the book: When you find a bug ask yourself "How can I
avoid this kind of bugs in the future?".
In this particular case, you can allocate an extra byte or int after the
300 moves and assign a weir number to it (e.g. 0xa6, whatever, not zero!). In
the debug version check that int to be 0xa6. If it is not, it has been
overwritten. I have seen this technique recommend it in other books that I
browsed. You can do this with every malloc making a wrapping function etc. This
kind of bugs are very difficult to debug so a good effort should be spent in
avoid them, IMHO.

Regards,
Miguel




This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.