views:

1245

answers:

9

Im sure this has happened to folks before, something works in debug mode, you compile in release, and something breaks.

This happened to me while working on a Embedded XP environment, the best way i found to do it really was to write a log file to determine where it would go wrong.

What are your experiences/ discoveries trying to tackle an annoying Release-mode bug?

A: 

If it's only a small portion of the application that needs debugging then you can change those source files only to be built without optimisations. Presumably you generate debug info for all builds, and so this makes the application run mostly as it would in release, but allows you to debug the interesting parts properly.

pauldoo
A: 

How about using Trace statements. They are there for Release mode value checking.

Trace.WriteLine(myVar);
Vin
+3  A: 

Make sure you have good debug symbols available (you can do this even with a release build, even on embedded devices). You should be able to get a stack trace and hopefully the values of some variables. A good knowledge of assembly language is probably also useful at this point.

My experience is that generally the bug is related to code that is near the area of breakage. That is to say, if you are seeing an issue arising in the function "LoadConfigInfoFromFile" then probably you should start by closely analysing that for issues, rather than "DrawControlsOnScreen", if you know what I mean. "Spooky action at a distance" type bugs do not tend to arise often (although when they do, they tend to be a major bear).

1800 INFORMATION
A: 

I agree on log file debugging to narrow it down.

I've used "Entering FunctionName" "Leaving FunctionName" until I can find what method it enters before the crash. Then I add more log messages re-compile and re-release.

Ed Haber
A: 

Besides playing with turning off optimization and/or turning on debug information for your Release build as pauldoo said, a log file will good data can really help. I once wrote a "trace" app that would capture trace logs for the app if it was running when the release build started (otherwise the results would go to the debugger's output window if running under the debugger). I was able to have end-users email me log files from them reproducing the bugs they were seeing, and it was the only way I would have found the problem in at least one case.

crashmstr
A: 

Though it's probably not usable in an embedded environment, I've had good luck with WinDbg for debugging release-mode Windows applications. Even if the application is not compiled with symbol information, you can at least get a usable stack trace and plenty of other useful crash information.

ElectricDialect
A: 

You could also copy your debug symbols to the production environment even if it's compiled in relase mode

Here's an article with more information

Juan Manuel
A: 

If you problem is synchronization related dumping log in the file might be problematic.
In this case i usually will use some big array of string and dump this to screen/file after the problem was reproduces.
This is of course depend on your memory restriction, sometime i use just few symbols and numbers to store in the array if the memory on the platform is limited. Reading such logs is not a big pleasure, but sometimes this is the only choice.

Ilya
+2  A: 

Tracefile is always a good idea. When it's about crashes, I'm using adplus, which is part of debugging tools for windows. basically what adplus does, is, it attaches windbg to the executable you're monitoring. When the application crashes, you get a crash dump and a log file. You can load the crash dump in your preferred debugger and find out, which instruction lead to the crash.

As release builds are heavily optimized compared to debug builds, the way you compile your code affects its behaviour. This is basically true when crashes in multithreaded code happen in the release version but not the debug version. adplus and windbg helped me, to find out, where this happened.

ADPlus is explained here: httx://support.microsoft.com/?scid=kb%3Ben-us%3B286350&x=15&y=12

Basically what you have to do is: 1. Download and install WinDbg into C:\debuggers httx://www.microsoft.com/whdc/devtools/debugging/default.mspx

  1. Start your application

  2. open a cmd and cd to c:\debuggers

  3. start adplus like this:

"adplus.bat -crash your_exe.exe"

  1. reproduce the crash

  2. analyze the crashdump in vs2005 or in windbg

primeMover