[Mono-bugs] [Bug 81974][Cri] New - GC crashes if there are more than about 160 threads.

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Jun 28 21:14:56 EDT 2007


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 patperry at stanford.edu.

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

--- shadow/81974	2007-06-28 21:14:56.000000000 -0400
+++ shadow/81974.tmp.6844	2007-06-28 21:14:56.000000000 -0400
@@ -0,0 +1,85 @@
+Bug#: 81974
+Product: Mono: Runtime
+Version: 1.2
+OS: All
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Critical
+Component: GC
+AssignedTo: lupus at ximian.com                            
+ReportedBy: patperry at stanford.edu               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: GC crashes if there are more than about 160 threads.
+
+Description of Problem:
+
+The garbage collector crashes if there are more than about 160 threads
+active at once.  This results in a deadlock.  
+
+
+Steps to reproduce the problem:
+
+1.Compile the program below and run it:
+
+using System;
+using System.Threading;
+
+public class ThreadBug
+{
+    public static int ThreadCount = 200;
+    
+    public static void ThreadTask ()
+    {
+        Thread.Sleep(1000);
+    }
+    
+    public static void Main ()
+    {
+        Thread[] threads = new Thread[ThreadCount];
+        
+        while (true) {
+            for (int i = 0; i < ThreadCount; i++) {
+                threads[i] = new Thread(ThreadTask);
+                threads[i].Start();
+            }
+        
+            for (int i = 0; i < ThreadCount; i++) {
+                threads[i].Join();
+            }
+
+            Console.WriteLine("Success!");
+        }
+    }
+
+}
+
+Actual Results:
+
+Deadlock
+
+Expected Results:
+
+Print "Success!" about once a second.  Note that if ThreadCount is changed
+to 100, the program runs fine.
+
+How often does this happen? 
+
+Always.
+
+Additional Information:
+
+The problem has been reported before, with C code to reproduce the problem: 
+
+http://bugzilla.ximian.com/show_bug.cgi?id=77470
+
+I am reporting the bug again to demonstrate that the problem has nothing to
+do with embedding the runtime.
+
+I'm pretty sure the comment from Brian Berg explains what the problem is. 
+The GC has an array of threads which is hardcoded to be of length 128. 
+Really, the array should grow dynamically if more than 128 threads are active.


More information about the mono-bugs mailing list