Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: a question about the value of checking bounds

Author: Tom Likens

Date: 11:04:58 01/21/03

Go up one level in this thread


On January 21, 2003 at 12:08:08, Uri Blass wrote:

Uri,

I use both BoundsChecker and the special patch that enables
gcc bounds checking under Linux.  The main version of my
program runs under Linux but I have a Windows make target
for the _sole_ purpose of using NuMega's BoundsChecker
on the program.

I've interspersed other comments in your original text below.

>I finished the time of my evaluation of checking bounds.
>
>It is expensive to buy it and before deciding if to buy it I
>want to know about the value of the alternatives.
>
>How many programmers use it?

I do.

>I talk about it with other programmers (not of chess programs
>and not in C).
>
>They suggested the following ideas:
>
>1) Not many people buy checking bounds and this is the reason
>   that the price is so high.
>
>2) checking bounds may be effective to check some work of other
>   programmers but programmers who work about their program do
>   not need it.

In my experience this is untrue.  It is useful no matter who is
writing the code.  The odds of you producing code that overwrites
an array bound is no less than some other anonymous programmer.
And the results are no less castastrophic.

>They suggested that it is better if I write functions to do it
>and replace all A[i]= with some f(A,i) that will also check for
>me if i is inside the bounds that are defined by A.  I said that
>I think that if I do it then my code will be at least twice slower.

This seems like needless runtime overhead, that a bounds checking
program or compiler will catch for free.

>I can also do a special slower code for debug (something that I
>do not do today) but I do not like the idea that every time that
>I add code then I will need to add also code for debugging.
>This may also make me slower in finding specific place that I
>want to change.

Use assertions.  They can be disabled for your release build
with zero overhead.

>I know that I may have bugs so practically after every small
>change I do some checking to see if I get the expected result
>by telling the program to print some information but I delete
>the code after finding that the program prints the right
>information.

Don't do this.  If debug scaffolding is useful once it will be
useful a hundred times.  You might bracket such code with

#ifdef DEBUG
#endif

statements.  It may offend your aesthetic sensibilities, but
having your program make some insane move in a future tournament
will probably bother you more.

>I am interested to read about the experience of programmers
>that use checking bounds.
>
>I have the following questions for them:
>
>1) Did checking bounds help you?
>2) Do you usually add code for debugging inspite of having
>   checking bounds?

1) Yes, bounds checking is a tremendous help.  It increases the
   "easier-to-sleep-at-night" quotient of your engine tremendously.

2) Yes, you will still need other debugging aids.  But you will
   no longer need homemade bounds checking code (which is difficult
   to implement and probably wrong anyway :(

>If 1 and 2 are  positive then question 3
>
>3)Do you decide to use less debugging code thanks to checking bounds?
>
>Uri

I know that NuMega has an evaluation period for BoundsChecker
so you could give that a whirl.  If you're using Linux then you
can download the bounds checking patch for gcc at:

http://gcc.gnu.org/extensions.html

By the way, I'm not a shill for NuMega, just a strong advocate
of bounds checking software.

regards,
--tom



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.