Archived

This topic is now archived and is closed to further replies.

IFooBar

strange problem with release and debug builds

Recommended Posts

hello i have a problem ...(as if you guys havent heard that sentence enough) anyway...i compile my 2d engine in debug and it compiles fine...the debugger has no warnings and the debug level of d3d is set to maximum, so assume there cant be anything wrong with the code. then i compiled the release version and it also compiled fine _but_ it crashes when u execute it? is this a strange thing or is this common. shouldnt the debug catch any c\glitches...especially with the highes debug output selected? thanks MY HQ

Share this post


Link to post
Share on other sites
It might be since the debug-mode will set all variables to 0 when you initialize them, while the retail won''t. So make sure you initialize them all.


--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

Share this post


Link to post
Share on other sites
Like tok_junior says the most common problem of builds working in debug and not release is due to debug setting all variables to 0 (a bad idea in my view) and release not. Often this rears its ugly head when you have forgotten to set a pointer to NULL so it is full of garbage. In debug you might get away with it as it will be set to NULL and code often has special case handling of null pointers e.g. it is perfectly valid to call delete with a null pointer. So fill your code from bottom to top with asserts and check every member variable in every class is initialised to a sensible default in the constructor.

Share this post


Link to post
Share on other sites
Yes, thats what I mean - it is ok to delete null, so in a debug version if you deleted a pointer before it was allocated it would be null by default and the delete would suceed but in release the pointer would be garbage so delete would try to delete a random bit of memory causing an unhandled exception

Share this post


Link to post
Share on other sites
hello

thanks for all the help. ive been debugging like made putting message boxes EVERYWHERE. ive finally found out where the problem is and why it fails. the problem is comming from
pd3d->EnumAdapterMode(...)
i use it in a for loop.
the for loop loops GetAdapterModeCount number of times. now it seems that GetAdapterModeCount is returning a number which is wrong. it returns 208 number of modes and once enumAdapterMode gets to around middle hundreds it fails and the program crashes even though i have an if(FAILED( macro there.
so i went to my display settings right and i saw modes that i have never seen before. i get modes upto 2048x1536
and im sure that before i had only up to mode 1024x768.
i guess in debug mode direct3d just ignores the wrong modes , but not the case with release mode thast why the release works for others but not for me (because my system assumes teh wrong number of supported modes)

now what to do. i have the latest drivers from nVidia already

thanks

Al Fareed
MY HQ

Share this post


Link to post
Share on other sites