[vmkit-commits] [vmkit] r145768 - /vmkit/trunk/tests/LockThread.java

Will Dietz wdietz2 at illinois.edu
Sat Dec 3 02:44:47 PST 2011


Author: wdietz2
Date: Sat Dec  3 04:44:46 2011
New Revision: 145768

URL: http://llvm.org/viewvc/llvm-project?rev=145768&view=rev
Log:
Simplify LockThread test: force too many fatlocks to be alloc'd, VM segfaults.

Modified:
    vmkit/trunk/tests/LockThread.java

Modified: vmkit/trunk/tests/LockThread.java
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tests/LockThread.java?rev=145768&r1=145767&r2=145768&view=diff
==============================================================================
--- vmkit/trunk/tests/LockThread.java (original)
+++ vmkit/trunk/tests/LockThread.java Sat Dec  3 04:44:46 2011
@@ -1,29 +1,26 @@
-// Some madness with threads and locks.  Shouldn't cause VM to crash!
+// Allocate too many fat locks, crash VM
 public class LockThread extends Thread {
   static Object Lock;
   static long x = 0;
-  static final long max = 1000000;
+  static final long max = 1000;
   public void run() {
     while(x < max)
       synchronized(Lock) {
         ++x;
-        if (x % 100 == 0)
-          ++x;
       }
   }
 
   public static void main(String[] args) {
-    Lock = new Object();
-    for(int iter = 0; iter < 100; ++iter) {
-      x = 0;
-      for(int i = 0; i < 100; ++i) {
-        new LockThread().start();
-      }
-      while(x < max)
-        Lock = new Object();
-      try {
-        sleep(100);
-      } catch(InterruptedException ignored);
+    for(int i = 0; i < 2048; ++i) {
+      Lock = new Object();
+
+      Thread t1 = new LockThread();
+      Thread t2 = new LockThread();
+      t1.start();
+      t2.start();
+
+      try { t1.join(); } catch (InterruptedException ignore){}
+      try { t2.join(); } catch (InterruptedException ignore){}
     }
   }
 }





More information about the vmkit-commits mailing list