Sign in to follow this  

Works in release not debug

This topic is 4135 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

I'm currently on a team developing a car combat game. As of right now in release mode, when one of our vehicles picks up a powerup and fires it, the projectile that is fired shows up just as it should. However, in debug mode, when the projectile is fired, it doesn't show up. I know that the projectile's render function is getting called and the correct data is being set, but I don't understand why it doesn't render. Has anyone encountered anything like this before, and if so, how did you solve/debug your way to the solution? Thanks in advance.

Share this post


Link to post
Share on other sites
I've encountered 4 occurences of code not having the same behaviour in Debug and in Release:

1 - ASSERT. This one has bitten me more than it should have! Putting some side-effect code into an ASSERT will lead to a different behaviour in release mode, as the code is removed.

2 - Bad code: If you write code that has undefined behaviour, then the optimized code might work differently that the non-optimized one. For example, reading an invalid memory address might crash in debug, but not in release, as by pure luck something happened to be here.

3 - Different libraries linking: Generally, librairies are released in debug and release modes, and the programmer links to the debug one in debug mode, and release one in release mode. Librairies might have different behaviour, if they have a different version, or if the debug one has some additional dump capabilities, for example.

4 - Compiler bug: It might happen that the compiler is just buggy, and generates code with different behaviour. Although this should be extremely rare, I've seen a case where it might have been the problem (I'm not too sure about it, I would blame myself before I would blame a compiler!).

Hope it helps, good luck!

Share this post


Link to post
Share on other sites
5. Unintialized code. AFAIK in debug builds all variables are initialized to some extent, in release build, don't. It might just happen that in debug mode all is ok, but in release the value of a varible is so bogus that it breaks things. Correct me if I am wrong.

Share this post


Link to post
Share on other sites
6. Using different folders for debug and release output and missing some files you use when loading them from the current directory. Like textures or models

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
make sure you don't see any of these around the projectile code:

#ifndef DEBUG

//projectile code
.
.
.

#endif

Share this post


Link to post
Share on other sites
The most common cause of different behaviour between release and debug modes is uninitialised variables or memory. The values are initialised differently by the compiler depending on the mode. So check for all uninitialised variables and memory blocks. I once created a little program that analysed all my classes to make sure that all member variables were initialised in the constructor as this kind of problem occurs so often and is so hard to track down.

Share this post


Link to post
Share on other sites

This topic is 4135 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this