[Mono-bugs] [Bug 55749][Maj] New - Another deadlock when running static constructors
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Thu, 18 Mar 2004 06:49:14 -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=55749
--- shadow/55749 2004-03-18 06:49:14.000000000 -0500
+++ shadow/55749.tmp.21025 2004-03-18 06:49:14.000000000 -0500
@@ -0,0 +1,76 @@
+Bug#: 55749
+Product: Mono: Runtime
+Version: unspecified
+OS: Red Hat 9.0
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: lluis@ximian.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Another deadlock when running static constructors
+
+The following test case deadlocks. It seems that the thread that runs the
+static constructor of the Broken class gets stuck inside the constructor,
+thus locking all other threads.
+
+Notice that the test case works sometimes, so you may need to run it
+several times before geting the deadlock.
+
+using System;
+using System.Threading;
+
+namespace BenchSoap
+{
+ public class Test
+ {
+ static int threadNumber = 10;
+
+ public static void Main ()
+ {
+ for (int i = 0; i < threadNumber; i++)
+ {
+ Thread t = new Thread (new ThreadStart (Work));
+ t.Start ();
+ Console.WriteLine ("started " + i);
+ }
+ Console.WriteLine ("no deadlock");
+ }
+
+ static void Work()
+ {
+ int n=0;
+ while (n<2)
+ {
+ try {
+ Console.WriteLine (n);
+ Broken.Doit ();
+ n++;
+ }
+ catch
+ {
+ }
+ }
+ }
+ }
+
+ public class Broken
+ {
+ static Broken ()
+ {
+ Console.WriteLine ("enter constructor");
+ for (int n=0; n<100000000; n++);
+ Console.WriteLine ("exit constructor");
+ }
+
+ public static void Doit ()
+ {
+ }
+ }
+}