Computer Chess Club Archives


Search

Terms

Messages

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

Author: Uri Blass

Date: 09:40:28 11/04/02

Go up one level in this thread


On November 04, 2002 at 12:25:00, Miguel A. Ballicora wrote:

>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 make sure that I do not have warning in level 3.
I had one warning in level 4 and I fixed it but it did not help to fix the
problem.

It is fixed if I do not use my previous wrong code but even if I xor 0's the
program is not supposed to crush.

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.