[Mono-bugs] [Bug 81538][Maj] New - ThreadAbortException doesn't get handled correctly, when it's thrown from inside a MethodInfo.Invoke call

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun May 6 13:31:36 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by lievenvanderheide at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=81538

--- shadow/81538	2007-05-06 13:31:36.000000000 -0400
+++ shadow/81538.tmp.5877	2007-05-06 13:31:36.000000000 -0400
@@ -0,0 +1,75 @@
+Bug#: 81538
+Product: Mono: Runtime
+Version: 1.2
+OS: GNU/Linux [Other]
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Major
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: lievenvanderheide at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: ThreadAbortException doesn't get handled correctly, when it's thrown from inside a MethodInfo.Invoke call
+
+Description of Problem:
+
+When aborting a thread, from a method that was called through 
+MethodInfo.Invoke, the ThreadAbortException changes to a TargetException 
+once it's outside the Invoke. It does still seem to behave like a 
+ThreadAbortException, as it does get rethrown at the end of the catch 
+block, but if you have a catch block that only catches 
+ThreadAbortException's, that catch block isn't called.
+
+Steps to reproduce the problem:
+1. Run the provided test case
+
+Actual Results:
+It outputs "b", which means that the exception that's being processed is 
+different from a ThreadAbortException.
+
+Expected Results:
+It should execute the catch(ThreadAbortException) block.
+
+How often does this happen? 
+Always
+
+Test Case:
+
+// project created on 5/6/2007 at 7:00 PM
+using System;
+using System.Threading;
+using System.Reflection;
+ 
+namespace BugTestCase
+{
+        class MainClass
+        {
+                public static void Main(string[] args)
+                {
+                        try
+                        {
+                                MethodInfo method = 
+typeof(MainClass).GetMethod("AbortIt");
+                                method.Invoke(null,new object[0]);
+                        }
+                        catch(ThreadAbortException e)
+                        {
+                                Console.WriteLine("a");
+                        }
+                        catch(Exception e)
+                        {
+                                Console.WriteLine("b");    
+                        }
+                }
+                
+                public static void AbortIt()
+                {
+                        Thread.CurrentThread.Abort();
+                }
+        }
+}


More information about the mono-bugs mailing list