[Mono-bugs] [Bug 78576][Nor] New - System.Threading.ReaderWriterLock: Releasing locks fails when writer lock is acquired before reader lock

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Jun 4 09:51:45 EDT 2006


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 h-ximian.com at skarab.com.

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

--- shadow/78576	2006-06-04 09:51:45.000000000 -0400
+++ shadow/78576.tmp.13466	2006-06-04 09:51:45.000000000 -0400
@@ -0,0 +1,89 @@
+Bug#: 78576
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: Linux 2.6.16-1.2122_FC5 #1 Sun May 21 15:01:01 EDT 2006 i686 athlon i386 GNU/Linux
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: h-ximian.com at skarab.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: System.Threading.ReaderWriterLock: Releasing locks fails when writer lock is acquired before reader lock
+
+Description of Problem:
+
+If a writer lock is acquired, then a reader lock, then upgraded to a writer
+lock, release the locks in the opposite order fails. I suspect the
+LockCookie implementation is insufficient.
+
+Steps to reproduce the problem:
+1. mcs ReaderWriterLockTest.cs
+2. mono ReaderWriterLockTest.exe
+3. Unhandled exception
+
+Actual Results:
+
+Inside inner-most lock
+
+Unhandled Exception: System.ApplicationException: The thread does not have
+any reader or writer locks.
+in <0x000ff> System.Threading.ReaderWriterLock:ReleaseReaderLock ()
+in <0x000b5> ReaderWriterLockTest.Test:Main (System.String[] args)
+
+Unhandled Exception: System.ApplicationException: The thread does not have
+the writer lock.
+in <0x00066> System.Threading.ReaderWriterLock:ReleaseWriterLock ()
+in <0x000cf> ReaderWriterLockTest.Test:Main (System.String[] args)
+
+Expected Results:
+
+Inside inner-most lock
+Success
+
+How often does this happen? 
+
+Always.
+
+Additional Information:
+
+ReaderWriterLockTest.cs
+-----------------------
+using System;
+using System.Threading;
+
+namespace ReaderWriterLockTest
+{
+        class Test
+        {
+                static void Main(string[] args)
+                {
+                        ReaderWriterLock rw = new ReaderWriterLock();
+                        rw.AcquireWriterLock(Timeout.Infinite);
+                        try {
+                                rw.AcquireReaderLock(Timeout.Infinite);
+                                try {
+                                        LockCookie lc =
+rw.UpgradeToWriterLock(Timeout.Infinite);
+                                        try {
+                                                Console.WriteLine("Inside
+inner-most lock");
+                                        } finally {
+                                               
+rw.DowngradeFromWriterLock(ref lc);
+                                        }
+                                } finally {
+                                        rw.ReleaseReaderLock();
+                                }
+                        } finally {
+                                rw.ReleaseWriterLock();
+                        }
+                        Console.WriteLine("Success");
+                }
+        }
+}


More information about the mono-bugs mailing list