views:

271

answers:

8

we have a dotnet 2.0 desktop winforms app and it seems to randomly crash. no stack trace, vent log, or anything. it just dissapears.

There are a few theories:

  1. machine simply runs out of resources. some people have said you will always get a window handle exception or a gdi exception but others say it might simply cause crashes.

  2. we are using wrappers around non managed code for 2 modules. exceptions inside either of these modules could cause this behavior.

again, this is not reproducible so i wanted to see if there were any suggestions on how to debug better or anything i can put on the machine to "catch" the crash before it happens to help us understand whats going on.

+6  A: 

Your best bet is to purchase John Robbins' book "Debugging Microsoft .NET 2.0 Applications". Your question can go WAY deeper than we have room to type here.

Boydski
+2  A: 

You could use Process Monitor from SysInternals (now a part of Microsoft) filtered down to just what you want to monitor. This would give you a good place to start. Just start with a tight focus or make sure you have plenty of space for the log file.

Scott
A: 

Do you have a try/catch block around the line 'Application.Run' call that starts the GUI thread? If not do add one and put some logging in for any exceptions thrown there.

You can also wrie up the Application.ThreadException event and log that in case that gives you some more hints.

BarneyHDog
A: 

you should use a global exception handler:
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.threadexception.aspx

Joel Martinez
+1  A: 

I agree with Boydski. But I also offer this suggestion. Take a close look at the threads if you're doing multi-threading. I had an error like this once that took a long long time to figure out and actually ended up with John Robbins on the phone helping out with it. It turned out to be improper exception handling with threads.

Max Schmeling
+3  A: 

Sounds for me like you need to log at first - maybe you can attach with PostSharp a logger to your methods (see Log4PostSharp) . This will certainly slow you down a lot and produce tons of messages. But you should be able to narrow the problematic code down ... Attach there more logs - remove others. Maybe you can stress-test this parts, later. If the suspect parts are small enough you might even do a code review there.
I know, your question was about debugging - but this could be an approach, too.

tanascius
I agree. Log the heck out of your code, then you should have a vague clue what was happening just before the crash. Add even more log messages to that area, and run again until you get a crash. Logs are great things, and how old-school programmers debugged in the days before IDEs and debuggers. :)
abelenky
And if it really crashes without calling catch/finally blocks there are not too many other options ...
tanascius
+1 - Logging is worth so much that it cannot be overestimated.
Fredrik Mörk
Logging is def a good idea. If you're not even seeing a .Net Runtime error event in the EventLog then I think you can be pretty sure you're problems are in the unmanaged code.
SpaceghostAli
A: 

I my past I have this kind of behaviour primarily in relation to COM objects not being released and/or threading issues. Dive into the suggestions that you have gotten here already, but I would also suggest to look into whether you properly release the non-managed objects, so that they do not leak memory.

Fredrik Mörk
+1  A: 

Run your app, with pdb files, and attach WinDbg, make run.
Whem crash occur WinDbg stop app.
Execute this command to generate dump file :

.dump /ma c:\myapp.dmp

An auxiliary tool of analysis is ADPlus

Or try this :

Capturing user dumps using Performance alert
How to use ADPlus to troubleshoot "hangs" and "crashes"
Debugging on the Windows Platform

lsalamon