Question:
I have a c++ application in visual studio 2005 which crashes in release mode?
angvz
2007-06-08 07:13:01 UTC
I have a c++ application in visual studio 2005 which reads processes and writes many files. It crashes in release mode but only when run from the command line outside of visual studio. The same release mode executable never crashes when run from the debugger - what is different ?
Four answers:
csanon
2007-06-08 07:39:20 UTC
> what is different ?

Check for uninitialised variables. Are you assuming any variables to be 0? That would be my first guess.



Otherwise, identify the section of code that causes a crash. Look at it for bad memory access and so on.



(Note: Going through the debugger may affect initial state of variables like setting them to 0. That is why I put that as my first guess. However, since you have posted no code, and no further information, I can't do more than guess.)
Chris C
2007-06-08 10:43:47 UTC
What about running it in debug mode in the Visual Studio IDE, and viewing the "Debug" window (you know press Alt+2, and the click on the "Debug" tab.

Then check for "error", or in worse case, check for "warning". Case insensitive search of course, and don't type the quotes.

That may point you to where you may have a problem.



Alternatively, if you had a debug log that could be created at run-time (whether in release mode or debug mode), you'd be better off.

I can't tell you how many applications I've come across that don't have that kind of functionality built in, and it drives me crazy. So, the first chance I get, I add that functionality to the project. After all, the code itself doesn't take up that much room in an application itself, and can be turned on/off as desired (even if you set levels like 0 - no debug log, 1-debug important things only, 2-debug semi-important things, 3-debug everything possible).



Even better yet, if it's a new project, you may want to create a simple class based off of CObject (or CWindow if necessary) that logs things as necessary, and have all your other classes based off of the new class you created.
hiltner
2016-10-09 15:52:33 UTC
i don't comprehend why human beings insist on eliminating stdafx.h use in seen studio. it extremely is there for a reason. particular, i comprehend maximum of you ultimate now make very trivial courses yet as they get larger you will celebrate with the earnings. It takes little or no to apply it and you may desire to get into the prepare. actually if I interviewed somebody and their pattern code I asked for did no longer have it i could low fee that guy or woman. shows a loss of expertise of the device. besides, sufficient soapbox. circulate the #contain and employing assertion into the stdafx.h created on your venture. Then positioned a #contain "stdafx.h" on your source record. Any time you utilize known libraries positioned their includes in stdafx.h. What this does is precompile the contain information and can extremely velocity up your build time. returned, extra significant for great courses with various library utilization yet a solid habit to improve.
2007-06-08 07:19:05 UTC
What is the error when it crashes ?

Does it work when you double click on it from Windows Explorer ?


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