[Mono-bugs] [Bug 55893][Nor] New - Mono Monitor fails on code which runs in MS.NET

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 22 Mar 2004 07:49:42 -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 larsde@key2network.com.

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

--- shadow/55893	2004-03-22 07:49:42.000000000 -0500
+++ shadow/55893.tmp.1744	2004-03-22 07:49:42.000000000 -0500
@@ -0,0 +1,77 @@
+Bug#: 55893
+Product: Mono: Runtime
+Version: unspecified
+OS: 
+OS Details: Debian Linux, running MONO/MCS from CVS (0.31.99)
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: larsde@key2network.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mono Monitor fails on code which runs in MS.NET
+
+Description of Problem:
+
+I am trying to implement a FIFO-queue that blocks on the dequeue-call until
+there are requests on the queue. I'm using the following mechanism:
+
+Thread A: (Consumer thread)
+
+// If no requests on queue
+lock (this) {
+  Monitor.Wait(this);
+}
+
+
+Thread B: (Producer thread)
+
+lock (this) {
+  // Enqueue request
+  Monitor.Pulse(this);
+}  // <-- My guess(!) is that this fails.
+
+Full source with NUnit-tests available on request.
+
+Steps to reproduce the problem:
+1. Lock an object in one thread and make call to Monitor.Wait(object);
+2. Lock the object in another thread.
+
+Actual Results:
+
+Monitor.Enter fail with:
+
+Unhandled Exception: System.Threading.SynchronizationLockException: Not
+locked by this thread
+in (unmanaged) /usr/local/lib/libmono.so.0(mono_raise_exception+0x1f)
+[0x40095fcf]
+in (unmanaged) /usr/local/lib/libmono.so.0(mono_monitor_exit+0x46) [0x400b4626]
+in (unmanaged) /usr/local/lib/libmono.so.0 [0x400b46d5]
+in <0x00023> (wrapper managed-to-native)
+System.Threading.Monitor:Monitor_exit (object)
+in <0x0003a> System.Threading.Monitor:Exit (object)
+in <0x0004e> Key2Network.Node.FIFO:Produce ()
+in <0x00038> Key2Network.Node.Tests.TestFIFO:ChangeToken ()
+in <0x00044> (wrapper delegate-invoke) System.MulticastDelegate:invoke_void ()
+
+.
+** ERROR **: file monitor.c: line 68 (mon_finalize): assertion failed:
+(mon->wait_list==NULL)
+aborting...
+
+
+Expected Results:
+
+Initial thread should wait to be restarted after the Monitor.Wait-call. The
+second thread should be able to get a lock on the object, and wake the
+first thread with a call to Monitor.Pulse(object). This is how it works
+with Microsoft .NET framework.
+
+How often does this happen? 
+
+100% reproducible.