Tuesday, July 14, 2009

I have a c++ application in visual studio 2005 which crashes in release mode?

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 ?

I have a c++ application in visual studio 2005 which crashes in release mode?
%26gt; 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.)
Reply:looks like it was strdup that was causing the problems Report It

Reply:What is the error when it crashes ?


Does it work when you double click on it from Windows Explorer ?
Reply: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.


No comments:

Post a Comment