How to debug why w3wp.exe crashes randomly?

A step-by-step guide is included here from Tess Ferrandez's blog:

https://blogs.msdn.com/b/tess/archive/2009/03/20/debugging-a-net-crash-with-rules-in-debug-diag.aspx

Essentially, you will setup DebugDiag 1.2 x64 to trigger on that exception code, and create a full userdump. After the dump is created, you can use DebugDiag to analyze the dump for you. Although with that particular exception, you probably need to use WinDbg+SOS.

Some of the more relevant information:

"For stack overflows as most of you probably know, the most common reason is that we are in some type of recursive loop, so what we really would like to know here is what is on this stack… The reason why it is showing up with just addresses and not method names, is because debug diag doesn’t understand .net so we’ll have to bring the dump to windbg to analyze it and check out the .net stack.

"In windbg we can then load up sos (.loadby sos mscorwks) and run !clrstack on the active stack to get the callstack."

(If you are running .NET 4, the command to load sos is: .loadby sos clr)

Ultimately, what you are looking for is the offending code in your application that is causing the recursion. The method names that appear in WinDbg when SOS is loaded will probably get you pointed in the right direction.


Get ProcDump and configure it to generate dumps when w3wp.exe processes crash. Once you have a dump inspect it with Visual Studio or Windbg.