[Mono-dev] (Nevermind) Asp.net thread abort issue

Joshua Tauberer tauberer at for.net
Mon Oct 10 10:27:48 EDT 2005

Gonzalo Paniagua Javier wrote:
> On Sun, 2005-10-09 at 08:04 -0400, Joshua Tauberer wrote:
>> Gonzalo Paniagua Javier wrote:
>>   > Anyway, if you ever decide to catch ThreadAbortException anywhere in the
>>> asp.net pipeline, bear in mind that it's used also when the configured
>>> timeout is reached.
>> The timeout for what?
> For the maximum request processing time set in machine.config/web.config
> (httpRuntime/executionTimeout).


>> For instance, if you abort the thread within a method called by 
>> reflection, when Invoke() finishes the exception is a 
>> TargetInvocationException and not a ThreadAbortException, confusing my 
>> catch clauses higher up.
> Yes, the behavior is right. However, a ThreadAbortException should be
> rethrown after the finally clause, even when catched, if ResetAbort() is
> not called.

The thing I was getting at is that you can't rely on catching 
ThreadAbortException to detect if Response.Redirect was called or if the 
processing has timed out -- the exception might be wrapped in another 
exception if the code executing at the time the exception was thrown was 
called with reflection.

All of the ThreadAbortException catches in HttpApplication, for 
instance, are potential problems.  Instead, you probably need to check
   (Thread.CurrentThread.ThreadState & ThreadState.AbortRequested) != 0
in every catch block.

What has been particularly strange, though, is the ThreadAbortExceptions 
appears to be thrown later on again after the first exception burried 
inside another exception was caught and ignored (without ResetAbort 
being called).  I think this is something I experienced (but couldn't 
reproduce in a small exe), and looks to be what's happening in the 
recent mono-list post "ASPX page randomly crashes."  (Well, maybe.)

Meanwhile, I found 1.1.8 RPMs on my box (I realized this morning that 
yum nicely keeps old RPMs hanging around a while) and went back to that, 
and my site is working smoothly again.  I think we need more advanced 
regression testing. :)  (That or my site was somehow relying on a bug 
that was fixed after 1.1.8.)  I don't know how I can help find the 
problems without taking my site down, though.

- Joshua Tauberer


** Nothing Unreal Exists **

More information about the Mono-devel-list mailing list