JDK-8031374 : TEST_BUG: java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java fails Intermittently
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 7u80,8,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-01-08
  • Updated: 2019-02-22
  • Resolved: 2019-02-22
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 9
9Fixed
Related Reports
Duplicate :  
Relates :  
Description
TESTFAIL:java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java

The test  java/util/concurrent/ConcurrentQueues/OfferRemoveLoops.java fails Intermittently. see logs:

----------System.out:(12/229)----------
LinkedBlockingQueue
LinkedBlockingQueue
LinkedBlockingDeque
LinkedBlockingDeque
ArrayBlockingQueue
PriorityBlockingQueue
ConcurrentLinkedDeque
ConcurrentLinkedQueue
LinkedTransferQueue

Passed = 10713698, failed = 6

----------System.err:(61/3359)----------
Hung thread: remover
java.lang.Thread.yield(Native Method)
OfferRemoveLoops$2.realRun(OfferRemoveLoops.java:123)
OfferRemoveLoops$1CheckedThread.run(OfferRemoveLoops.java:94)
java.lang.ThreadDeath
	at java.lang.Thread.stop(Thread.java:849)
	at OfferRemoveLoops.testQueue(OfferRemoveLoops.java:152)
	at OfferRemoveLoops.test(OfferRemoveLoops.java:52)
	at OfferRemoveLoops.instanceMain(OfferRemoveLoops.java:171)
	at OfferRemoveLoops.main(OfferRemoveLoops.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:746)
	at java.lang.Thread.run(Thread.java:744)
Hung thread: remover
java.lang.Thread.yield(Native Method)
OfferRemoveLoops$2.realRun(OfferRemoveLoops.java:123)
OfferRemoveLoops$1CheckedThread.run(OfferRemoveLoops.java:94)
java.lang.ThreadDeath
	at java.lang.Thread.stop(Thread.java:849)
	at OfferRemoveLoops.testQueue(OfferRemoveLoops.java:152)
	at OfferRemoveLoops.test(OfferRemoveLoops.java:54)
	at OfferRemoveLoops.instanceMain(OfferRemoveLoops.java:171)
	at OfferRemoveLoops.main(OfferRemoveLoops.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:746)
	at java.lang.Thread.run(Thread.java:744)
Hung thread: remover
java.lang.Thread.yield(Native Method)
OfferRemoveLoops$2.realRun(OfferRemoveLoops.java:123)
OfferRemoveLoops$1CheckedThread.run(OfferRemoveLoops.java:94)
java.lang.ThreadDeath
	at java.lang.Thread.stop(Thread.java:849)
	at OfferRemoveLoops.testQueue(OfferRemoveLoops.java:152)
	at OfferRemoveLoops.test(OfferRemoveLoops.java:56)
	at OfferRemoveLoops.instanceMain(OfferRemoveLoops.java:171)
	at OfferRemoveLoops.main(OfferRemoveLoops.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:746)
	at java.lang.Thread.run(Thread.java:744)
java.lang.AssertionError: Some tests failed
	at OfferRemoveLoops.instanceMain(OfferRemoveLoops.java:173)
	at OfferRemoveLoops.main(OfferRemoveLoops.java:169)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at com.sun.javatest.regtest.MainAction$SameVMRunnable.run(MainAction.java:746)
	at java.lang.Thread.run(Thread.java:744)

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

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


test result: Failed. Execution failed: `main' threw exception: java.lang.AssertionError: Some tests failed
Comments
Hoping the jsr166 CVS integration resolves this.
21-09-2015

This needs to be closed as a dup of 8035661.
11-06-2014

As discussed in open, we're closing this as cannot reproduced and bring the code fix from jsr166 CVS. Bug https://bugs.openjdk.java.net/browse/JDK-8035661 was opened for bringing it to openjdk repo http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-February/025281.html
04-03-2014

Code fix has been sent code open review: http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-February/025267.html
23-02-2014

I agree we shouldn't use Thread.stop here. I will fix it when fixed the bug. But this is not the root cause of the bug. As you comment here "sleep will certainly give up the CPU, whereas yield is not required to." , you're right at this also. I should fix it as well. But it's still not the root cause, root cause is in slow machine, a loop wait is also one problem. I think I have to fix all there of them.
23-02-2014

Root Cause: In slow machine, when offer elements's number doesn't reach 1024 and timeout, remove thread will wait the condition until it reach i % 1024 == 0; since the machine is pretty slow. Wait condition i % 1024 == 0 be satisfied may take a lot of time. Suggested Fix: Change quittingTime(long i){ return i % 1024 == 0 && quittingTime(); } to quittingTime(long i){ return quittingTime() && (i % 1024 == 0 || i < 1024); } This make sure thread stop as earlier as possible when running in slow machine.
23-02-2014

sleep will certainly give up the CPU, whereas yield is not required to. I see ThreadDeath in the stack trace - which is a really bad sign. Who is using Thread.stop()?
23-02-2014

This test failed in Windows, yield or sleep can't be guarantee current thread give up CPU execution. Especially in windows. This can be proved to add System.out.println in remover thread protected void realRun() { .... System.out.println("remove " + c); Thread.yield(); We can see a lot of remove xxx. By reproduce this bug, easiest way is a simulation for Thread.yield() but with more time consuming call. Which I choose Thread.sleep(20). After adding Thread.sleep(20) in method realRun of remover. This failure can be reproduced in many the time. run: LinkedBlockingQueue offer 0 remove 1 offer 1 offer 2 offer 3 offer 4 offer 5 offer 6 offer 7 offer 8 offer 9 offer 10 offer failed 11 ...(535 times offer failed 11) remove 11 offer 11 offer 12 offer 13 offer 14 offer 15 offer 16 offer 17 offer 18 offer 19 offer 20 offer failed 21 ...(488 times offer failed 21) remove 21 offer 21 offer 22 offer 23 offer 24 offer 25 offer 26 offer 27 offer 28 offer 29 offer 30 offer failed 31 ...(358 times offer failed 31) offer 31 remove 32 offer 32 offer 33 offer 34 offer 35 offer 36 offer 37 offer 38 offer 39 offer 40 offer 41 offer failed 42 ...(205 times offer failed 42) remove 42 offer 42 offer 43 offer 44 offer 45 offer 46 offer 47 offer 48 offer 49 offer 50 offer 51 offer failed 52 ...(216 times offer failed 52) offer 52 offer failed 53 offer failed 53 offer 53 offer 54 remove 55 offer 55 offer 56 offer 57 offer 58 offer 59 offer 60 offer 61 offer 62 offer 63 offer 64 offer failed 65 ...(408 times offer failed 65) remove 65 offer 65 offer 66 offer 67 offer 68 offer 69 offer 70 offer 71 offer 72 offer 73 offer 74 offer failed 75 ....(219 times offer failed 75) offer 75 offer 76 offer 77 offer 78 offer 79 offer 80 offer 81 offer 82 offer 83 offer 84 offer failed 85 remove 75 offer failed 85 ...(209 offer failed 85) remove 85 offer 85 offer 86 offer 87 offer 88 offer 89 offer 90 offer 91 offer 92 offer 93 offer 94 offer failed 95 316 offer failed 95 offer 95 offer 96 offer 97 offer 98 offer 99 remove 100 offer 100 offer 101 offer 102 offer 103 offer 104 offer 105 offer 106 offer 107 offer 108 offer 109 offer failed 110 ... (41 offer failed 110) remove 110 ... (497 remove 110) Hung thread: remover java.lang.Thread.sleep(Native Method) OfferRemoveLoops$2.realRun(OfferRemoveLoops.java:127) OfferRemoveLoops$1CheckedThread.run(OfferRemoveLoops.java:94) java.lang.ThreadDeath at java.lang.Thread.stop(Thread.java:849) at OfferRemoveLoops.testQueue(OfferRemoveLoops.java:161) at OfferRemoveLoops.test(OfferRemoveLoops.java:52) at OfferRemoveLoops.instanceMain(OfferRemoveLoops.java:180) at OfferRemoveLoops.main(OfferRemoveLoops.java:178) Passed = 120, failed = 2 Exception in thread "main" java.lang.AssertionError: Some tests failed at OfferRemoveLoops.instanceMain(OfferRemoveLoops.java:182) at OfferRemoveLoops.main(OfferRemoveLoops.java:178) Java Result: 1 BUILD SUCCESSFUL (total time: 10 seconds)
23-02-2014

Tried 100 times loop run, not reproduced. Also note test only failed on boundary queue.
10-02-2014