Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Thanks Felipe Bergo!

Author: Heiner Marxen

Date: 12:09:40 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 :)

See also my general hints elsewhere in this thread.

As for the movelist overrun: I've been faced with the exact same problem
at some time.  Generally, you should never ever fill any array without
an explicit overrun check.

Now, the problem with these checks is: they are tedious and slow down the code.
For move list generation I have used the following trick:
- First, I fill the array without any overrun check.  Fast and easy.
- Then, when the move list is complete, and I may have already overrun it,
  and destroyed important data, but before I return from the generating
  function, I check the effectively filled length against the allocated size,
  and if an overrun is detected, I do an explicit panic() which tells me
  exactly what is the problem.  A board dump would also be helpful, here.

So, the overhead is very small, both, the runtime overhead and the coding
overhead, and the problem is detected before any desaster happenes.
I like it  :-))

Regards,
Heiner



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.