Question:
Crash during execution in release mode?
jonny91
2006-12-07 04:47:56 UTC
I am using Microsoft VC++ ide,
when i run my application (programming language used is C ) in DEBUG mode it executes successfully.
But when in run the same application in RELEASE mode the application will crash .giving an error which states:

"The instruction at 0x0033333" referenced memory at "0x00333333".
The memory could not be "read" "

I am not able to find the code where the error exists because in release mode the ide does not show the code,it shows some assembly code.
In debug mode the ide does show the source code but my appliction runs successfully.


Any software/ide that can detect this kind of error and point to the source code instead of some assembly code?

Or

Any other way to detect the error in the source code ?

please help?
Four answers:
Rah-Mon Heur
2006-12-07 06:54:34 UTC
There is a couple of differences between debug and release mode. But two majors one might concern you here.



First memory allocated in debug is padded with a couple of bytes before and after each block to allow verification of memory integrity.



And second, many object are initialized with zeros in debug but not in release.



So, I suggest you enable all run-time checks in your project configuration for both targets and rerun your tests. If the crash is caused by writing / reading out of the region that belong to you, that should catch it in debug, and you could see where is that happening.



For the second case, simply make sure you initialize all your variables when declaring them so that their state is known at all time.



Good luck!
dm_dragons
2006-12-07 13:36:20 UTC
The code in release or debug mode is on the same machine? If not, then debug on the computer that errors.



In general, you have a memory error that is most likely to do the size of the data. For example, the buffer size isn't large enough to handle a string size you are using. The string type is the culprit 9 times out of 10, so review these variables - the ones you defined.



You could and even should have error trapping in your code whichi would write the information you need to a database table.



Good Luck,
rentaprogrammer
2006-12-07 14:55:13 UTC
From time to time you will encounter problems that only show themselves in Release Mode. I've been using VC++ 6 for about 10 years and I've probably seen this about a dozen times. Here's what you do:



Find out where the problem is in the source (how do you do that you ask)? It's a process of elimination. Add some simple message boxes (MessageBox) before and after the code block you expect has the problem. Start very general at first (add a messagebox before every procedure call in the top level procedure or event handlers (Winproc?) you believe could be breaking) and narrow it down (move the message boxes into the procedure that broke) as you find out which procedure is bugging you. Eventually you will have it narrowed down to one statement.



One really wacky thing I found was that some data was not being initialized properly. The Debugger was gracious enough to initialize it for me. Release Mode threw out all the optimizations and let that data be used without initializing.
ballarke
2006-12-07 17:26:40 UTC
Here's how to help you debug this. On your project, modify the Release settings to enable debugging mode. Enable the debugging options both under the C++ settings and Linker settings. This will attach debugging information to your executable that will allow you to run it in a debugger, but keep the optimization information on the executable that will allow you to diagnose this problem.



I'm a professional programmer and have run into this exact kind of problem several times. What I've described above has allowed me to diagnose and correct this problem, with no extra software required.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...