Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: need an advice how to detect a bug

Author: Miguel A. Ballicora

Date: 09:25:00 11/04/02

Go up one level in this thread


On November 03, 2002 at 12:39:51, Robert Hyatt wrote:

>On November 03, 2002 at 10:38:20, Uri Blass wrote:
>
>>I found that there is a bug in the latest version of movei and it seems based on
>>page 130 of the book "the practice of programming" that it is a memory
>>allocation error.
>>
>>I see different behaviour in debug configuration and in release configuration.
>>I also saw different behaviour when I only added one printf.
>>
>>My question is what is the fastest way to detect the bug.
>
>The most likely reason is an uninitialized local variable.  It gets allocated
>on the stack, and if you call different things, the stack contents will have
>different random values for such variables.
>
>If you have a "lint" program, run it on the source.  These things are pretty
>good at detecting such stuff.  If you are using gcc, or if you can use gcc,
>use -O to optimize, and -Wall to turn on all warnings.  The -O option turns
>on the code to build the dependency graph for each function, showing which
>variables are set where and used where, for optimization.  But in doing this,
>the compiler will spot places where local variables are used before they are
>initialized or set.

Uri, if you are using the Microsoft compiler turn the level warnings to 3 (at
least) and make sure that you do not have any warnings. It is even a good idea
(IMHO) not to have any warnings at even level 4, but that might be too much.
The latter is debatable.

Miguel


>
>
>>
>>I have a lot of arrays and adding a code to check if I wrote outside the
>>allocated memory in every place is a lot of work.
>>
>>I think that it may be better if the compiler can do it for me(or maybe the
>>compiler can do it and I do not know how it can do it).
>>
>>Is there a reason that prevent the compiler to check only in debug mode that
>>what I put in the arrays make sense before putting the information in the
>>arrays?
>>
>>Note that I save previous versions of movei and I may try to compare number of
>>nodes in debug mode and release mode to try to find the latest version that has
>>the bug but the problem is that I cannot know that I have not the bug from
>>identical output and I can only know that I have a bug when the output is not
>>identical.
>>
>>Uri



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.