1

I have a windows c# application (WPF) - it's quite large and a lot of multithreading is going on.

My problem is that i know of several deadlocks which exist in the application here and there first - and secondly - i am afraid to release it without a way of detecting potential new ones and without the capability of somehow being reported back to us.

The application has a companion - a small executable (wpf c# again) called Launcher - it is used to launch the real process from itself.

Why? Because i am redirecting all error and outer output when the main application crashes - to the Launcher.

In turn - when a crash is detected - the launcher launches another executable - BugReports - passes the error information to it.

Later on - BugReports submits this info and some user entered comments to a web service.

The setup is like this:

Launcher - used to launch the main app and detect when it exits MainApp - started by Launcher BugReports - launched by Launcher - when a crash has been detected. Crash information obtained by Launcher is passed by command line to BugReports. It submits the info to a web service.

Confusing i know :)

This works perfectly for unhandled exceptions butt.....

In the last version of Launcher i decided to integrate a WatchDog timer. It is supposed to monitor MainApp every 30 seconds and detect if it is in a locked up situation (deadlock for example).

If it detects that - it will kill it and launch BugReports again.

Works perfectly - every time the MainApp stalls - it is detected and all the necessary processes work as they should.

THE PROBLEM:

I need to obtain a 'snapshot' somehow of the threads state in MainApp - where they are at (module, method), what state they are in and whatever more useful information i can obtain so we can find out where the potential deadlock has occurred.

Now i've looked up half the internet and i am not able to find out such i thing the way i want it.

Basically - the idea is to obtain a birds eye look - as if i were pausing the MainApp in the visual studio debugger and could check out where each thread is at and what the problem is.

Is this possible?

Any guidelines to what should i dig into more?

Thanks, Martin K.

Martin Kovachev
  • 442
  • 4
  • 18

3 Answers3

1

It's possible but not easy! If you write by your own you're about to start something really funny but time consuming. Once I had to do the same thing (more or less) and I used MSE (Managed Stack Explorer). It's hosted on CodePlex and you can use its core library without any user interface (for perfect integration in your tool).

Adriano Repetti
  • 65,416
  • 20
  • 137
  • 208
0

Debugger -> Windows -> Parallel Stacks

I think this is new to VS2012 recent version and exists in VS2013, I'm not sure. I actually just found this this morning...

http://msdn.microsoft.com/en-us/library/dd998398.aspx

I hope this helps anybody who stumbles across this thread! Really cool feature!

Sprague
  • 1,610
  • 10
  • 22
0

Consider minidumps instead of stacks (note privacy concerns).

Check out this for Error reporting What is the best way to collect crash data?, including info on Windows Error Reporting, and this thread - Recreate stack trace with line numbers from user bug-report in .net?.

You also can create minidump yourself with MiniDumpWriteDump.

NOTE: Process dump contains user's personal information. You should make sure to understand problems and regulations associated with copying user's personal information to your machines. Privacy concerns also applies to other crash/hang reporting.

Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • Thanks! After a lot of work, testing and reading it is working :) I had to also copy the SOS.dll file from the client's machines as it seems sometimes it is not available from the symbol servers but it is awesome now! – Martin Kovachev Mar 27 '12 at 13:55