What are the typical reasons for bugs and abnormal program behavior that manifest themselves only in release compilation mode but which do not occur when in debug mode?
It's possible. If it happens and no conditional compilation is involved, than you can be pretty sure that your program is wrong, and is working in debug mode only because of fortuitous memory initializations or even layout in memory!
Other differences might be:
The CRT library functions behave differently in debug vs release (/MD vs /MDd).
For example, the debug versions often prefill buffers you pass to the indicated length to verify your claim. Examples include strcpy_s
, StringCchCopy
, etc. Even if the strings terminate earlier, your szDest better be n bytes long!
There are compiler optimizations that can break valid code because they are too aggressive.
Try compiling your code with less optimization turned on.
I remember while ago when we were building dll and pdb in c/c++.
I remember this:
And then kept at going through that cycle.
We sometimes, temporarily swapped release for debug versions of dlls, in order not to hold off production, while working on these bugs.
Another reasons could be DB calls. Are you saving and updating same record multiple times in same thread, sometimes for updating. Its possible the update failed or didnt work as expected because the previous create command was still processing and for update, the db call failed to find any record. this wont happen in debug as debugger makes sure to complete all pending tasks before landing.