[rvm-research] Bug in Classpath's VMProcess w.r.t. use of notify() instead of notifyAll()

Carl Ritson <[email protected]>
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <CAKDym5M2tgYpbxAB1qFEuAqUeCcVDWJquBVtK1XyHmr5_14zoQ@mail.gmail.com>
Hi,

I've been chasing a bug which causes benchmarks from Dacapo 2006 to
hang with the concurrent collector we are implementing.  I've tracked
the source of the bug to VMProcess in Classpath.  VMProcess performs a
notify() on state changes rather than notifyAll(), this means that if
one thread calls waitFor() on a Process object waiting for its
termination and another calls destroy() then only one of the two will
be woken up.

This occurs during stress testing with Dacapo 2006's Eclipse benchmark
which calls external commands with a timeout.  Under high load the
external processes do not finish within the timeout period and
destroy() is called.  At the same time Eclipse's process monitor
thread is waiting in waitFor().  Only the waitFor() thread detects
termination, the destroy() thread is never resumed.

The attached program can reproduce the bug in miniature with any
version of Jikes compiled against Classpath.  This can be fixed by
applying the attached patch to classpath any version.

Cheers,

Carl

------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr

_______________________________________________
Jikesrvm-researchers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jikesrvm-researchers
classpath-vmprocess-notify.diff (application/octet-stream, 848 B)
--- a/vm/reference/java/lang/VMProcess.java
+++ b/vm/reference/java/lang/VMProcess.java
@@ -152,7 +152,7 @@ final class VMProcess extends Process
                     {
                       process.exitValue = exitValue;
                       process.state = TERMINATED;
-                      process.notify();
+                      process.notifyAll();
                     }
                 }
               else
@@ -214,7 +214,7 @@ final class VMProcess extends Process
               process.state = TERMINATED;
               process.exception = t;
             }
-          process.notify();
+          process.notifyAll();
         }
     }
   }
@@ -243,7 +243,7 @@ final class VMProcess extends Process
           }
         else
           {
-            workList.notify();
+            workList.notifyAll();
           }
       }
ProcessTerminationTest.java (application/octet-stream, 1.9 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.