How to debug random crashes?

we have a winforms desktop application dotnet 2.0 and it seems to accidentally crash. no stack trace, input log or anything else. he just disappears.

There are several theories:

  • the car just ran out of resources. some people have stated that you always get a window exception or a gdi exception, but others say this can lead to crashes.

  • we use wrappers around unmanaged code for 2 modules. exceptions from one of these modules can cause this behavior.

again, this is not reproducible, so I wanted to see if there are any suggestions on how to debug better or anything that I can put on the machine to “catch” the crash before this happens, to help us understand , what's happening.

+4
source share
8 answers

It's best to buy John Robbins ' book Debugging Microsoft.NET 2.0 Applications . Your question may go WAY deeper than we have a place to enter here.

+6
source

It sounds to me the way you need to log in first - perhaps you can attach PostSharp to your methods ( see Log4PostSharp ). This will certainly slow you down and produce a ton of messages. But you have to narrow the problem code down ... Attach more logs there - delete others. Maybe you can stress test these parts later. If the suspicious parts are small enough, you can even view the code overview.
I know your question was about debugging - but it could be an approach too.

+3
source

You can use Process Monitor from SysInternals (now part of Microsoft), filtered to what you want to control. This will give you a good place to start. Just start with limited focus or make sure you have enough space for the log file.

+2
source

I agree with Boydsky. But I also offer this suggestion. Look at threads if you are doing multithreading. I had a mistake similar to this situation, and it took a long time to understand, and actually ended up with John Robbins on the phone, helping him. This turned out to be an incorrect exception handling with threads.

+1
source

Launch the application, with pdb files and attach WinDbg, run the run.
Whem crashes using the WinDbg stop application.
Run this command to create the dump file:

.dump / ma c: \ myapp.dmp

ADPlus Assistant Analysis Tool

Or try the following:

Capture user dumps using performance alerts
How to use ADPlus to troubleshoot "freezes" and "crash"
Windows debugging

+1
source

Do you have a try / catch block around the "Application.Run" line that starts the GUI thread? If not, add one and enter some entries for any exceptions that were selected there.

You can also break the Application.ThreadException event and the log, which is in case you get some more tips.

0
source

In the past, I had this behavior, primarily due to the fact that COM objects are not released and / or problems with threads. Immerse yourself in the proposals that you have already received here, but I would also suggest examining whether you are freeing unmanaged objects correctly so that they do not leak memory.

0
source

Source: https://habr.com/ru/post/1285768/


All Articles