Works in Debug but not Release Mode

Started by
5 comments, last by iMalc 12 years, 4 months ago
Hi guys, I'm using VS2010 C++ and my game works in debug mode but gets a 'program has stopped working' in release mode.

I know it's a memory/array/bad pointer problem but how am I supposed to figure it out if there seems to be no error in debug mode ?

What should I do ?

Thanks.
Advertisement
Run it under the debugger even though it's a release build. That should at least get you some hints as to where the crash is occurring.

Wielder of the Sacred Wands
[Work - ArenaNet] [Epoch Language] [Scribblings]

A very likely cause is that you're forgetting to initialize either a pointer or some memory properly, so check through your allocations.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

If it's not a case of using an uninitialized variable, which in my experience is the most common thing that causes works-in-debug-doesn't-work-in-release, then look for buffer overruns. I think debug builds have more padding in the stack or something (somebody correct me on this if I'm wrong) but it generally seems like stomping on random memory is more likely to cause a crash in Release than Debug.
Which compiler are you using?
You guys were right, I was using a pointer to an uninitialized structure so I guess it's pretty hard for the compiler to catch. It's good to know it will cause that type of error because it's happened to me before and instead of trying to figure it out I'd revert to a backup.
Generally in a debug build variables are initialised to 0, this is why it wouldn't crash in debug (only if you checked the variable was valid before use).

Generally in a debug build variables are initialised to 0, this is why it wouldn't crash in debug (only if you checked the variable was valid before use).

I'm not sure what compiler that is, but in Microsoft Visual Studio uninitialised variables have the value 0xCCCCCCCC (length dependent on actual data type). This is specifically non-zero because the most common intentional initialisation value is zero so it is more likely to pick up a bug. Also it is that exact value because it is easily recognisable in the debugger. IIRC it is also typically not a valid memory address, leading to an instant access violation if code tries to dereference it.
"In order to understand recursion, you must first understand recursion."
My website dedicated to sorting algorithms

This topic is closed to new replies.

Advertisement