sbt / sbt-jcstress

Trust no-one, and especially not memory visibility.
http://kto.so
19 stars 6 forks source link

java.lang.IllegalStateException during execution #12

Open retronym opened 6 years ago

retronym commented 6 years ago

I'm trying to set up a jcstress suite for scala/scala (for https://github.com/scala/scala/pull/6425)

I created a project and dropped in one of the sample tests from the tests in this repo.

I ran into:

Auxiliary data
JVM options: [-XX:+UnlockDiagnosticVMOptions, -XX:+StressLCM, -XX:+StressGCM] Iterations: 5 Time: 1000

java.lang.IllegalStateException
    at org.openjdk.jcstress.vm.WhiteBoxSupport.tryDeopt(WhiteBoxSupport.java:117)
    at org.openjdk.jcstress.infra.runners.Runner.run(Runner.java:84)
    at org.openjdk.jcstress.EmbeddedExecutor.lambda$task$0(EmbeddedExecutor.java:81)
    at org.openjdk.jcstress.EmbeddedExecutor.run(EmbeddedExecutor.java:72)
    at org.openjdk.jcstress.ForkedMain.main(ForkedMain.java:58)

I patched jcstress to show the underlying exception.

diff -r 64f2cf32fa0a jcstress-core/src/main/java/org/openjdk/jcstress/vm/WhiteBoxSupport.java
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/vm/WhiteBoxSupport.java  Fri Jan 26 18:57:29 2018 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/vm/WhiteBoxSupport.java  Tue May 29 12:00:04 2018 +1000
@@ -114,7 +114,7 @@
                             w.deoptimizeMethod(m);
                         }
                     } catch (IOException e) {
-                        throw new IllegalStateException();
+                        throw new IllegalStateException(e);
                     }
                     break;
                 default:

To find:

(java_use 9; java -cp lib/jcstress-core-0.5-SNAPSHOT.jar:target/jars/net.sf.jopt-simple/jopt-simple/jopt-simple-4.6.jar:/Users/jz/code/scala/test/jcstress/target/scala-2.13.0-pre-SNAPSHOT/test-classes:/Users/jz/code/scala/test/jcstress/target/scala-2.13.0-pre-SNAPSHOT/classes:/Users/jz/code/scala/test/jcstress/lib/jcstress-core-0.5-SNAPSHOT.jar:/Users/jz/code/scala/test/jcstress/../../build/pack/lib/scala-library.jar:/Users/jz/.ivy2/cache/org.openjdk.jcstress/jcstress-core/jars/jcstress-core-0.4.jar:/Users/jz/.ivy2/cache/net.sf.jopt-simple/jopt-simple/jars/jopt-simple-4.6.jar org.openjdk.jcstress.Main )
Java Concurrency Stress Tests
---------------------------------------------------------------------------------
Rev: 64f2cf32fa0a+, built by jz with 9.0.4 at 2018-05-29T01:38:27Z

Probing what VM modes are available:
 (failures are non-fatal, but may miss some interesting cases)

----- [OK] [-Xint]
----- [OK] [-XX:TieredStopAtLevel=1]
----- [OK] []
----- [OK] [-XX:+UnlockDiagnosticVMOptions, -XX:+StressLCM, -XX:+StressGCM]
----- [OK] [-XX:-TieredCompilation]
----- [OK] [-XX:-TieredCompilation, -XX:+UnlockDiagnosticVMOptions, -XX:+StressLCM, -XX:+StressGCM]

Initializing and probing the target VM:
 (all failures are non-fatal, but may affect testing accuracy)

----- [OK] Unlocking diagnostic VM options
Burning up to figure out the exact CPU count....... done!

----- [OK] Trimming down the default VM heap size to 1/8-th of max RAM
----- [OK] Trimming down the number of compiler threads
----- [OK] Trimming down the number of parallel GC threads
----- [OK] Trimming down the number of concurrent GC threads
----- [OK] Trimming down the number of G1 concurrent refinement GC threads
----- [FAILED] Testing @Contended works on all results and infra objects
Exception in thread "main" java.io.IOException: java.lang.NullPointerException
    at org.openjdk.jcstress.util.Reflections.ensureResourceInited(Reflections.java:51)
    at org.openjdk.jcstress.util.Reflections.getClassNames(Reflections.java:77)
    at org.openjdk.jcstress.util.Reflections.getClasses(Reflections.java:60)
    at org.openjdk.jcstress.vm.ContendedTestMain.main(ContendedTestMain.java:43)
Caused by: java.lang.NullPointerException
    at org.openjdk.jcstress.util.Reflections.enumeratePath(Reflections.java:115)
    at org.openjdk.jcstress.util.Reflections.enumerate(Reflections.java:102)
    at org.openjdk.jcstress.util.Reflections.enumerate(Reflections.java:93)
    at org.openjdk.jcstress.util.Reflections.ensureResourceInited(Reflections.java:49)
    ... 3 more

Still digging into what that means.

retronym commented 6 years ago

Okay, the problem is that the classpath element /Users/jz/code/scala/test/jcstress/target/scala-2.13.0-pre-SNAPSHOT/classes doesn't exist at all in my project, which NPEs at:

for (File f : d.listFiles()) {

One workaround is to add a dummy classfile to generate that directory.

jcstress ought to be more defensive about its inputs, but I the meantime hopefully this issue will help others find the workaround.