Jump to content
  • Advertisement
Sign in to follow this  
Endemoniada

Works in Debug but not Release Mode

This topic is 2526 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!