[Mono-bugs] [Bug 55909][Wis] New - Deadlock in ReaderWriterLock.UpgradeToWriterLock()
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Mon, 22 Mar 2004 13:04:25 -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 mono-bug@jerryweb.info.
http://bugzilla.ximian.com/show_bug.cgi?id=55909
--- shadow/55909 2004-03-22 13:04:25.000000000 -0500
+++ shadow/55909.tmp.3766 2004-03-22 13:04:25.000000000 -0500
@@ -0,0 +1,95 @@
+Bug#: 55909
+Product: Mono: Class Libraries
+Version: unspecified
+OS: GNU/Linux [Other]
+OS Details: Gentoo
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: mono-bug@jerryweb.info
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Deadlock in ReaderWriterLock.UpgradeToWriterLock()
+
+Description of Problem:
+Deadlock in ReaderWriterLock.UpgradeToWriterLock()
+
+Steps to reproduce the problem:
+
+Run this code:
+===================================================================
+using System;
+using System.Threading;
+
+namespace Example {
+ class Class1 {
+ static ReaderWriterLock _rwl = new ReaderWriterLock();
+ const int _timeout = Timeout.Infinite;
+
+ [STAThread]
+ static void Main(string[] args) {
+ Thread th = new Thread(new ThreadStart(Thread2));
+ th.Start();
+ Thread.Sleep(1000);
+ Console.WriteLine("1 - AcquireReaderLock, before");
+ _rwl.AcquireReaderLock(Timeout.Infinite);
+ Console.WriteLine("1 - AcquireReaderLock, after");
+ try {
+ Console.WriteLine("1 - UpgradeToWriterLock, before");
+ LockCookie lc = _rwl.UpgradeToWriterLock(_timeout);
+ Console.WriteLine("1 - UpgradeToWriterLock, after");
+ Thread.Sleep(500);
+ Console.WriteLine("1 - Release, before");
+ }
+ finally { _rwl.ReleaseReaderLock(); }
+ Console.WriteLine("1 - End");
+ }
+
+ static void Thread2() {
+ Console.WriteLine("2 - AcquireReaderLock, before");
+ _rwl.AcquireReaderLock(Timeout.Infinite);
+ Console.WriteLine("2 - AcquireReaderLock, after");
+ try {
+ Thread.Sleep(3000);
+ Console.WriteLine("2 - UpgradeToWriterLock, before");
+ LockCookie lc = _rwl.UpgradeToWriterLock(_timeout);
+ Console.WriteLine("2 - UpgradeToWriterLock, after");
+ Thread.Sleep(2000);
+ Console.WriteLine("2 - Release, before");
+ }
+ finally { _rwl.ReleaseReaderLock(); }
+ Console.WriteLine("2 - End");
+ }
+ }
+}
+===================================================================
+
+Actual Results:
+
+MS.NET 1.0:
+2 - AcquireReaderLock, before
+2 - AcquireReaderLock, after
+1 - AcquireReaderLock, before
+1 - AcquireReaderLock, after
+1 - UpgradeToWriterLock, before
+2 - UpgradeToWriterLock, before
+1 - UpgradeToWriterLock, after
+1 - Release, before
+1 - End
+2 - UpgradeToWriterLock, after
+2 - Release, before
+2 - End
+
+Mono 0.31, Gentoo Linux:
+2 - AcquireReaderLock, before
+2 - AcquireReaderLock, after
+1 - AcquireReaderLock, before
+1 - AcquireReaderLock, after
+1 - UpgradeToWriterLock, before
+2 - UpgradeToWriterLock, before
+...???