[Mono-bugs] [Bug 39474][Wis] New - ThreadStateException handling during the finally clause

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Tue, 11 Mar 2003 08:31:24 -0500 (EST)


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 matthias204@mac.com.

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

--- shadow/39474	Tue Mar 11 08:31:24 2003
+++ shadow/39474.tmp.5569	Tue Mar 11 08:31:24 2003
@@ -0,0 +1,115 @@
+Bug#: 39474
+Product: Mono/Runtime
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Gentoo Linux 1.4rc2 / mono 0.23
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: matthias204@mac.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: ThreadStateException handling during the finally clause
+
+Description of Problem:
+If a ThreadStateException is thrown, the finally clause is exceuted and 
+after that the exceptions is rethrown. If another exception is thrown, 
+this exception is thrown and can be caught.
+Then the Microsoft CLR continues the execution, while mono rethrows the 
+ThreadStateException.
+
+
+Steps to reproduce the problem:
+	class Class1
+	{
+		public static void bla()
+		{
+			try
+			{
+				Console.WriteLine("Thread started ... 
+waiting");
+				Thread.Sleep(10*1000);
+			}
+			catch( ThreadAbortException ) {}
+			finally
+			{
+				try
+				{
+					string blaa = null;
+					try
+					{
+						Console.WriteLine( 
+blaa.ToString() );
+					}
+					catch( Exception e ) { 
+Console.WriteLine( e.ToString() ); }
+					Console.WriteLine("The will apear 
+on ms CLR!");
+				}
+				catch( Exception e )
+				{
+					Console.WriteLine("\nThis 
+exception is not thrown on ms CLR:");
+					Console.WriteLine( e.ToString() );
+				}
+			}
+		}
+		[STAThread]
+		static void Main(string[] args)
+		{
+			Thread myThread = new Thread( new ThreadStart( 
+bla ) );
+			myThread.Start();
+			Thread.Sleep( 3000 );
+			Console.WriteLine("Aborting Thread");
+			myThread.Abort();
+			Console.WriteLine("Joining Thread");
+			myThread.Join();
+			Console.WriteLine("Done");
+			Console.ReadLine();
+		}
+	}
+
+Actual Results:
+Thread started ... waiting
+Aborting Thread
+Joining Thread
+System.NullReferenceException: A null value was found where an object 
+instance was required
+in [0x00020] (at /home/matthias/Development/mono/Class1.cs:25) 00 
+ThreadAbortTest.Class1:bla ()
+
+
+This exception is not thrown on ms CLR:
+System.Threading.ThreadAbortException: Thread was being aborted
+in (unmanaged) /lib/libc.so.6(__libc_nanosleep+0x11) [0x402064b1]
+in (unmanaged) mono(Sleep+0x60) [0x811207d]
+in (unmanaged) mono
+(ves_icall_System_Threading_Thread_Sleep_internal+0x1f) [0x80de18e]
+in <0x00075> 00 System.Threading.Thread:Sleep (int)
+in [0x0000a] (at /home/matthias/Development/mono/Class1.cs:12) 00 
+ThreadAbortTest.Class1:bla ()
+in [0x00033] (at /home/matthias/Development/mono/Class1.cs:24) 00 
+ThreadAbortTest.Class1:bla ()
+
+Done
+
+
+Expected Results:
+Thread started ... waiting
+Aborting Thread
+Joining Thread
+System.NullReferenceException: Object reference not set to an instance of 
+an object.
+   at ThreadAbortTest.Class1.bla() in m:\visual studio 
+projects\threadaborttest\class1.cs:line 22
+The will apear on ms CLR!
+Done
+
+How often does this happen? 
+everytime