[Mono-bugs] [Bug 56157][Nor] New - Exception calling Monitor.Exit twice

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 29 Mar 2004 07:14:19 -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 lluis@ximian.com.

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

--- shadow/56157	2004-03-29 07:14:19.000000000 -0500
+++ shadow/56157.tmp.24384	2004-03-29 07:14:19.000000000 -0500
@@ -0,0 +1,49 @@
+Bug#: 56157
+Product: Mono: Runtime
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lluis@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Exception calling Monitor.Exit twice
+
+The following test case fails in Mono:
+
+using System;
+using System.Threading;
+
+class Test
+{
+	static void Main(string [] args )
+	{
+		Test t = new Test ();
+		Monitor.Enter (t);
+		Monitor.Exit (t);
+		Monitor.Exit (t);
+	}
+}
+
+Looking at the documentation for Monitor.Exit, this failure seems correct,
+since it states that a SynchronizationLockException is thrown if the
+current thread does not own the lock for the specified object.
+
+However, it does work on MS.NET. Any Monitor.Exit call after a
+Monitor.Enter call in the same block will succeed. This allows constructs
+such as:
+
+		Test t = new Test ();
+		lock (t)
+		{
+			Monitor.Exit (t);
+		}
+
+that works on MS.NET but fails on Mono.