PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

why does debug version not show bugs that release does?

I'm in the last few weeks of game development & trying to once & for all find out why I get some wierd PocketPC errors. They don't happen in debug version only release. Based on all the previous posts by myself & others in this area it looks like i'm getting data corruption but the problem is nailing it down as debug version runs like a dream.

I'm going to start logging lots of values to find what happens. I know that the data is there correctly because other functions display the correct values but this one particular function which display's a single trade item which a planet is selling shows the first trade item instead of the chosen one (ie: item 0) ond often gets an exception violation.

Dan East explained how to get some debug info into the release version but this has not allowed me close enough to find the error.
Pejo Software - Per · 26 Apr 2004, 10:58 UTC
Memory is handled differently in debug mode! So if you are overwriting memory the symptom often is that it works in debug mode but not in release mode :cry: .
I know its painfull to think about it. But there are bugs in the compiler which come up when you maximise for speed. Often Debug options are not compatible with /O2 although you could of set anything by now in the development. If you turn off speed or size options do the errors go away.

A thought on the above bit, doesn't debug fill zero's in memory and release not.
Memory allocated in a debug build also has padding on either end of the array. It is supposed to be used to check if the array was overwritten, but Windows CE debugger doesn't check it.

So to rehash what has already been said:

Try building individual source files Release build with all optimizations turned off.

Make sure you aren't reading dynamically allocated data before the data is initialized.

Watch for writing past the end (or beginning) of dynamically allocated arrays. Just a single byte will cause problems - but only in a Release build.

Dan East
Jinks is write, the optimizer can also screw things up. Happened to me a few times. Try a build without optimizations.
Debug also initializes variables. For example...

Code:


bool NeedInit;

void SomeFunc()
{
if(NeedInit)
{
RunIntialization();
}
DoSomethingElse();
}



So, in a Debug build, NeedInit will get set to (i think) 0xcdcdcdcd, which will evaluate to true and RunInitialization() is called. In Release Build, NeedInit doesn't get intialized and takes on the value of what ever happens to be in memory... some maybe RunInitialization() gets called or maybe it doesn't.

You can try and make a Release/Debug build for testing. That is, copy a Release build settings and include debug information for the linker, then run your app in the debugger. With any luck, the bug will still happen and you can now 'see' where it is.

Cheers,

rcp
If you really want to know what your app is doing, download the Entrek Toolbox - it is fantastic. I've been using the trial version the last couple of days and it has picked up so many stupid little errors in my apps that had all sorts of bad consequences.

http://www.entrek.com/
Thanks for all the help. I have plenty of things to try. I know that before entering the function which crashes the data seems to be fine. The function before this one is a list of all trade goods for sale or purchase and the one which is buggy is the individual item display. If the list works the individual should as well. I may just trash the function & re-write on the assumption that I'm just not seeing the obvious.

I like the sound of the toolkit but don;t really want to try the demo & like it too much as it's $500 however I will give it a go if needed.

( The Joy of programming )
Like I said else where recently, I recommend writing your own memory wrapper functions which have error checking..these will definately check your memory problems, you can also then check memory problems even when optimizations are on, then on release you use a version with out your memory debug.
So many bugs tend to be down to memory screw ups it an investment to write such code.

Jim.
What compiler are you using? This is important information.

I wouldn't suspect memory bugs until it is shown to be the case, I'd equally suspect the compiler, if you are still using eVC3. Which is to say, don't waste time writing your own memory handling functions before you've tried different compiler settings (which is easier).

What is in the function you suspect? This is important information. I have found eVC3 to screw up switches and if-else-if statements.
I'm currently using the V3 compiler. I did download the V4 one but held off installing as someone had written that V3 produced faster code.

When I can't find anything else to do re: game coding I will try the V4 compiler.
That's often a hallmark of optimizer errors: code that is too fast because half of it has been incorrectly optimzed away. The Digital UNIX 64bit optimizer produced blazing fast code that was notorious for optimization errors.

Let me ask this question: if the code produced is wrong, does it matter how fast it is?

I'd been bitten a few times by v3 optimizer errors. I switched to v4 and never looked back. I trust v3 about as far as I can throw it. I came to the conclusion that the reason it was given away for free, is who would buy such an incomplete (no exceptions, RTTI, iostreams, etc.) and buggy product?
Stay away from EVC3's ARM compiler. I've heard many times that it generates bad code. EVC4 seems much more stable (I have yet to see a problem with it).

Funny thing is I've heard the opposite: that EVC4's ARM compiler generates faster code then EVC3's.
Thierry wrote:

Funny thing is I've heard the opposite: that EVC4's ARM compiler generates faster code then EVC3's.


With my tests EVC4 generate bigger code but not faster code, about the same speed..
here another thing to try:

if you have issues with different application behaviour in release/debug (ofcourse release versions make the problems, since most of us run their programs most of the time in debug, so it usually runs fine there) then enable debug information for release builds and have a look into what happens in the release code...

bye,
Daniel
Conan · 01 Jun 2004, 11:56 UTC — progress report
as suggested by J Edwards above I downloaded the demo of the Entrek TOOLBOX. This showed that in certain places I was allocating bucketloads of memory within loops without ever freeing it. This always happens in the same way and I have already nailed down my splash screen as one contender for memory leak queen of the month and the cut scene where trade goods get ejected as another. Hopefully with some more hard work I will slay the memory bugs soon.

Strange that debug mode survives my rampant memory usage where release does not.
EVC4 seems much more stable (I have yet to see a problem with it).


I recently found a bug when trying to compile DosBox. Try something like this

Code:


template <int a>
int add (int b) {
return a + b;
};

int (*fp)(int);

fp = add<1>;



When trying to assing the template function instance to the function pointer, the compiler complains about not beeing able to convert the values.
I tried VC6 (latest service pack) and EVC4....both show the error. With VC.NET it works as intended :)

Tala
you managed to compile dosbox for ppc ? what version ?
(I'm very interested in that but maybe it is not the right thread to ask...)
Tala wrote:
When trying to assing the template function instance to the function pointer, the compiler complains about not beeing able to convert the values.
I tried VC6 (latest service pack) and EVC4....both show the error. With VC.NET it works as intended :)

Tala

I had a very similar problem here http://www.pocketmatrix.com/forums/viewtopic.php?p=208182#208182

so even if the compiler does not complain, it might still generate incorrect code(!).

- HM
Conan · 12 Jun 2004, 06:37 UTC — Found the problem at last
My crashes came from bad data due to my reading in values from a text file & not correctly converting them to numbers. Sometimes the value was suitable, other times not hence the intermittent crashes. Once that bug was fixed it pointed to another one.

Now the game is running without crashing every few games so I can get on with the beta testing.

btw: it looks like this:-
Image
*runs to PocketGamer*

Would you mind Conan?
Hi Sponge, sorry for being slow but I don't know what you mean about PocketGamer. If you mean telling PG about the game no problem. It's just about ready to go & I have several new screen shots to put up on my site shortly.