Quantcast
Channel: MSDN Blogs
Viewing all articles
Browse latest Browse all 12366

How to use CrashDiag to capture Stack Overflow exception dump in MVC Web APP on Microsoft Azure

$
0
0

This article is to show how to capture a real stack overflow exception happened in MVC web app on Azure. Actually after reading you will find this method can be used to solve other web apps which has intermittent 1st chance exception issues.

The sample MVC web app is from a small test project from https://github.com/freistli/Dev14_Net46_Mvc5/tree/StackOverflow. When run it and click the Contact menu, the application will immediately exit and shows this error on Azure Web App:

clip_image002

In this sample, we know it is a fatal c00000fd exception (native stackoverflow exception). If in real production situation cannot retrieve the code info from event log or other logs, can contact Microsoft Support Team to see if can get exit code from backend logging tables.

To further investigate the exception, we expect to take the crash dump exactly when the exception happens. Now let’s use CrashDiag:

1. Install Crash Diagnoser site extension from the Azure Site Extension Gallery from Azure Portal. For details refer to this article.

2. Browse the extension (https://yourtestapp.scm.azurewebsites.net/cashdiag). Click the 1st chance exception tab, set the setting as:

clip_image003

Please notice The Managed Exception option is selected as “No” because it is a crash on native exception code c00000fd

The reason we don’t configure and capture 2nd chance unhandled exception for the MVC app is ASP.NET by default captures unhandled 1st chance exceptions in HTTP Context directly and makes an exit. It quits directly after those “fatal” 1st chance exceptions without throwing 2nd chance exception.

If you saw StackOverflowException exception code was recorded in d:\home\logfiles\eventlog.xml, it means the exception is managed exception:

<Data>w3wp.exe</Data><Data>IIS APPPOOL\TestWeb</Data><Data>StackOverflowException</Data><Data>Operation caused a stack overflow.
at testWeb._Default.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()

Then you should set exception code as “overflow” or “StackOverflowException”, Managed Exception as “Yes”:

clip_image005

3. Click the Start button. The CrashDiag starts monitoring w3wp process.

4. Once the c00000fd exception happens, the dump can be generated automatically.

clip_image007

Then we can use debugging tool (Windbg or DebugDiag) to debug the dump to see how the exception happens. This sample dump shows calls tack as below, then it accurately points to the Foo() function caused the process termination:

0:22:> kL

ChildEBP RetAddr

059ce610067755f6 Dev14_Net46_Mvc5!Dev14_Net46_Mvc5.Controllers.HomeController.Foo()059ce610067755f6 Dev14_Net46_Mvc5!Dev14_Net46_Mvc5.Controllers.HomeController.Foo()+0x6059ce610067755f6 Dev14_Net46_Mvc5!Dev14_Net46_Mvc5.Controllers.HomeController.Foo()+0x6059ce610067755f6 Dev14_Net46_Mvc5!Dev14_Net46_Mvc5.Controllers.HomeController.Foo()+0x6059ce610067755f6 Dev14_Net46_Mvc5!Dev14_Net46_Mvc5.Controllers.HomeController.Foo()+0x6059ce610067755f6 Dev14_Net46_Mvc5!Dev14_Net46_Mvc5.Controllers.HomeController.Foo()+0x6059ce610067755f6 Dev14_Net46_Mvc5!Dev14_Net46_Mvc5.Controllers.HomeController.Foo()+0x6

privatevoid Foo()
        {
         Foo();
        }

Thanks

-Freist Li from APGC DSI Team


Viewing all articles
Browse latest Browse all 12366

Trending Articles