Home > Net >  Azure - App crashed because of Stack Buffer Overrun Exception HTTP 502 errors
Azure - App crashed because of Stack Buffer Overrun Exception HTTP 502 errors

Time:06-02

We are stuck with an issue while hosting our application on the Azure app service. Can someone help us to find the root cause of the issue? Also please post if more information is required.

We are getting this issue while trying to establish a database connection. Our database also exists on Azure as SQL Managed Instance and we are using Active Directory Managed Identity to create the connection.

Your app crashed because of Stack Buffer Overrun Exception and aborted the requests it was processing when the overflow occurred. As a result, your app’s users may have experienced HTTP 502 errors

This call stack caused the exception:

InlinedCallFrame
InlinedCallFrame
DomainBoundILStubClass.IL_STUB_PInvoke
Microsoft.Data.SqlClient.SNILoadHandle..ctor
Microsoft.Data.SqlClient.SNILoadHandle..ctor
Microsoft.Data.SqlClient.SNILoadHandle..cctor
GCFrame
HelperMethodFrame
Microsoft.Data.SqlClient.TdsParser..cctor
GCFrame
HelperMethodFrame
Microsoft.Data.SqlClient.TdsParser..ctor
Microsoft.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover
Microsoft.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist
Microsoft.Data.SqlClient.SqlInternalConnectionTds..ctor
Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnection
Microsoft.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection
Microsoft.Data.ProviderBase.DbConnectionPool.CreateObject
Microsoft.Data.ProviderBase.DbConnectionPool.UserCreateRequest
Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection
Microsoft.Data.ProviderBase.DbConnectionPool.TryGetConnection
Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection
Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal
Microsoft.Data.SqlClient.SqlConnection.TryOpenInner
Microsoft.Data.SqlClient.SqlConnection.TryOpen
Microsoft.Data.SqlClient.SqlConnection.Open
mmd.DBConnection.establishConnection
NewAuthentication.OnPageLoad
System.Web.UI.Control.OnLoad
System.Web.UI.Control.LoadRecursive
System.Web.UI.Page.ProcessRequestMain
System.Web.UI.Page.ProcessRequest
System.Web.UI.Page.ProcessRequest
System.Web.UI.Page.ProcessRequest
ASP.classic_common_newauthentication_aspx.ProcessRequest
System.Web.HttpApplication CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
System.Web.HttpApplication <>c__DisplayClass285_0.b__0
System.Web.HttpApplication.ExecuteStepImpl
System.Web.HttpApplication.ExecuteStep
System.Web.HttpApplication PipelineStepManager.ResumeSteps
System.Web.HttpApplication.BeginProcessRequestNotification
System.Web.HttpRuntime.ProcessRequestNotificationPrivate
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification
DomainNeutralILStubClass.IL_STUB_ReversePInvoke
InlinedCallFrame
InlinedCallFrame
DomainNeutralILStubClass.IL_STUB_PInvoke
System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper
System.Web.Hosting.PipelineRuntime.ProcessRequestNotification
DomainNeutralILStubClass.IL_STUB_ReversePInvoke
ContextTransitionFrame

CodePudding user response:

A crash of a process happens when the process terminates due to an unhandled exception within the application code.

A crash leads to a restart and all the in-flight requests (requests currently being handled by the process) are aborted abruptly and may fail with an HTTP 502 error.

Proactive Crash Monitoring is a feature of Azure App Service that checks for process crashes and collects diagnostic data that helps you determine the root cause of the crash.

Note: Currently offered in App Service Diagnostics for Windows web apps.

Whenever the worker process (w3wp.exe) corresponding to your app crashes due to an unhandled exception for more than 3 times in 24 hours on the same instance, the feature is enabled automatically and a debugger process is attached to your site’s main worker process.

This debugger process then waits for your process to crash again and, assuming it does crash again, a memory dump is collected. This memory dump is then analyzed and the call stack of the thread that caused the crash is logged in your App Service’s logs.

For Viewing Crashing thread information:

Follow the below steps to view the crashing thread’s call-stack.

  1. Open the Diagnose and Solve blade for the app (in the left-side navigation menu)

  2. Choose Availability and Performance category

  3. Choose Application Crashes tool

  4. If this feature has collected a crashing thread stack trace, you will find an insight like in the image below

    Application Crashes Detector in Diagnose and Solve problems

    Application Crashes Detector in Diagnose and Solve problems

CodePudding user response:

Thanks Everyone,

The issue was with the latest version of Microsoft.Data.SqlClient. As per the article below we downgraded the package and our issue was fixed.

https://weblog.west-wind.com/posts/2021/Dec/07/Connection-Failures-with-MicrosoftDataSqlClient-4-and-later

  • Related