Skip to content

Exception: System.Threading.ThreadAbortException cause process terminated #49666

@ds-kong

Description

@ds-kong

Description

We have event log indicate that TAE crashing the process.
An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/6/ROOT/Signing

Process ID: 45536

Exception: System.Threading.ThreadAbortException

Message: Thread was being aborted.

StackTrace: at System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotificationHelper(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)
at System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(IntPtr rootedObjectsPointer, IntPtr nativeRequestContext, IntPtr moduleData, Int32 flags)

Reproduction Steps

In .net framework 4.8
Have a EmptyController, it redirect to empty.aspx page.

using System.Web.Mvc;
[RoutePrefix("empty")]
public class EmptyController : Controller
{
[HttpGet]
public ActionResult Index()
{
return Redirect("~/empty.aspx");
}
}

And create an Empty.aspx page. in Empty.aspx.cs, have HttpContext.Current.Response.End(); in OnUnload life Cycle event, and also catch TAE, but do nothing.
using System;
using System.Web;
using System.Web.UI;
public class Empty : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Code-behind logic goes here
}
protected override void OnUnload(EventArgs e)
{
try
{
//HttpContext.Current.Response.Redirect("https://www.google.com/");
HttpContext.Current.Response.End();
}
catch (System.Threading.ThreadAbortException)
{
}
}
}

When you try to hit that controller. ~/empty, it will redirect to empty.aspx, and the process will crash. Should find process terminated event log.
Directly hit ~/empty.aspx won't crash the process. Not sure why controller play a role here.

Expected behavior

The TAE shouldn't crashing the process any time.

Actual behavior

The process crash.

Regression?

There are other link talking about this.

https://stackoverflow.com/questions/33001299/intermittent-crash-of-w3wp-exe-with-threadabortexception-after-net-4-6-upgrade

Known Workarounds

don't have that catch(TAE) section or in Catch(TAE) section, add Thread.ResetAbort()
In both ways, the process won't crash.

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions