JDK-7058828 : test/java/util/concurrent/Phaser/Arrive.java fails intermittently
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 7,8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2011-06-24
  • Updated: 2013-01-03
  • Resolved: 2012-05-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u2Fixed 8 b01Fixed
Related Reports
Duplicate :  
Relates :  
Description
This test failed once for me in JPRT on linux-x64. This is jdk8 b01 (which is essentially the same as jdk7-b146).



TEST: java/util/concurrent/Phaser/Arrive.java
JDK under test: (/tmp/jprt/P2/T/093317.ab23780/testproduct/linux_x64_2.6-product)
java version "1.8.0-internal"
Java(TM) SE Runtime Environment (build 1.8.0-internal-201106240933.ab23780.jdk-b00)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b16, mixed mode)

ACTION: build -- Passed. Build successful
REASON: Named class compiled on demand
TIME:   0.036 seconds
messages:
command: build Arrive
reason: Named class compiled on demand
elapsed time (seconds): 0.036

ACTION: compile -- Passed. Compilation successful
REASON: .class file out of date or does not exist
TIME:   0.035 seconds
messages:
command: compile /tmp/jprt/P2/T/093317.ab23780/source/test/java/util/concurrent/Phaser/Arrive.java
reason: .class file out of date or does not exist
elapsed time (seconds): 0.035

ACTION: main -- Failed. Execution failed: `main' threw exception: java.lang.AssertionError: Some tests failed
REASON: Assumed action based on file name: run main Arrive 
TIME:   120.01 seconds
messages:
command: main Arrive
reason: Assumed action based on file name: run main Arrive 
elapsed time (seconds): 120.01
STDOUT:

Passed = 20, failed = 1

STDERR:
java.lang.InterruptedException
	at java.lang.Object.wait(Native Method)
	at java.lang.Thread.join(Thread.java:1258)
	at java.lang.Thread.join(Thread.java:1332)
	at Arrive.test(Arrive.java:72)
	at Arrive.instanceMain(Arrive.java:91)
	at Arrive.main(Arrive.java:89)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:680)
	at java.lang.Thread.run(Thread.java:722)
java.lang.AssertionError: Some tests failed
	at Arrive.instanceMain(Arrive.java:93)
	at Arrive.main(Arrive.java:89)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:680)
	at java.lang.Thread.run(Thread.java:722)

JavaTest Message: Test threw exception: java.lang.AssertionError
JavaTest Message: shutting down test


TEST RESULT: Failed. Execution failed: `main' threw exception: java.lang.AssertionError: Some tests failed

Comments
EVALUATION Equate number of threads and registered parties. JDK8 changeset: Changeset: 549b7c3f0bdc Author: dl Date: 2011-07-12 15:23 +0100 URL: http://hg.openjdk.java.net/jdk8/tl/jdk/rev/549b7c3f0bdc 7058828: test/java/util/concurrent/Phaser/Arrive.java fails intermittently Reviewed-by: chegar ! test/java/util/concurrent/Phaser/Arrive.java
12-07-2011

EVALUATION This test just started to fail with jdk8 ( failure NOT seen in jdk7 b146 ). Previously the test only ever ran with 1 thread! The reason is that ThreadLocalRandom.current().nextInt(1, 10) always returned 1. Since the fix for 7051516: "ThreadLocalRandom seed is never initialized so all instances generate the same sequence", the test now actually is running with a number of threads between 1-10. I believe the test is misguided. It has more threads simultaneously arriving than registered parties. There is a race; In thread A the final party arrives, it does some internal state processing for the phaser, onAdvance, increment phase number, etc. Another thread may invoke arrive() while thread A is doing this, it will find that the unarrived count is -1 ( unarrived = (counts & UNARRIVED_MASK) - 1; ) and throw IllegalStateException. I believe this to be a test problem/usage error because of the arrive() specification: "It is a usage error for an unregistered party to invoke this method. However, this error may result in an IllegalStateException only upon some subsequent operation on this phaser, if ever."
24-06-2011