-
Type:
Bug
-
Resolution: Fixed
-
Priority:
P4
-
Affects Version/s: 25, 26
-
Component/s: hotspot
-
b21
-
s390x
-
linux
| Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
|---|---|---|---|---|---|---|
| JDK-8370576 | 25.0.2 | Vladimir Petko | P4 | Resolved | Fixed | b04 |
test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java does not contain negative test cases for compareAndExchange and compareAndSwap.
Adding those:
-----
diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java b/test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java
index 01e015d50cb..297d1b848ce 100644
+++ b/test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java
@@ -879,6 +879,12 @@ public void runAtomicTests() {
Object oldVal2 = testCompareAndExchange(o, oldVal, newVal);
Asserts.assertEquals(oldVal, oldVal2);
Asserts.assertEquals(o.f, newVal);
+ // test failing compareAndExchange
+ Object newExpected = new Object();
+ Object newSetValue = new Object();
+ Object old = testCompareAndExchange(o, newExpected, newSetValue);
+ Asserts.assertEquals(newVal, old);
+ Asserts.assertEquals(o.f, newVal);
}
{
Outer o = new Outer();
@@ -888,6 +894,13 @@ public void runAtomicTests() {
boolean b = testCompareAndSwap(o, oldVal, newVal);
Asserts.assertTrue(b);
Asserts.assertEquals(o.f, newVal);
+ Object newSetValue = new Object();
+ Object old = testCompareAndExchange(o, newExpected, newSetValue);
+ Asserts.assertEquals(newVal, old);
+ Asserts.assertEquals(o.f, newVal);
}
{
Outer o = new Outer();
@@ -888,6 +894,13 @@ public void runAtomicTests() {
boolean b = testCompareAndSwap(o, oldVal, newVal);
Asserts.assertTrue(b);
Asserts.assertEquals(o.f, newVal);
+ // test failing compareAndSwap
+ Object newExpected = new Object();
+ Object newSetValue = new Object();
+ boolean failed = testCompareAndSwap(o, newExpected, newSetValue);
+ Asserts.assertFalse(failed);
+ Asserts.assertEquals(o.f, newVal);
+
}
{
----
makes the test fail on S390x platform:
----------
Test Failures (1)
-----------------
Custom Run Test: @Run: runAtomicTests - @Tests: {testCompareAndExchange,testCompareAndSwap,testGetAndSet,testCompareAndExchangeOnNewObject,testCompareAndSwapOnNewObject,testGetAndSetOnNewObject,testGetAndSetConditionallyOnNewObject,testGetAndSetOnNewObjectAfterException,testGetAndSetOnNewObjectAfterCall}:
compiler.lib.ir_framework.shared.TestRunException: There was an error while invoking @Run method public void compiler.gcbarriers.TestG1BarrierGeneration.runAtomicTests()
at compiler.lib.ir_framework.test.CustomRunTest.invokeTest(CustomRunTest.java:162)
at compiler.lib.ir_framework.test.AbstractTest.run(AbstractTest.java:105)
at compiler.lib.ir_framework.test.CustomRunTest.run(CustomRunTest.java:89)
at compiler.lib.ir_framework.test.TestVM.runTests(TestVM.java:865)
at compiler.lib.ir_framework.test.TestVM.start(TestVM.java:255)
at compiler.lib.ir_framework.test.TestVM.main(TestVM.java:168)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at compiler.lib.ir_framework.test.CustomRunTest.invokeTest(CustomRunTest.java:159)
... 5 more
Caused by: java.lang.RuntimeException: assertEquals expected: java.lang.Object@460f76a6 but was: java.lang.Object@55f3c410
at jdk.test.lib.Asserts.fail(Asserts.java:715)
at jdk.test.lib.Asserts.assertEquals(Asserts.java:208)
at jdk.test.lib.Asserts.assertEquals(Asserts.java:195)
at compiler.gcbarriers.TestG1BarrierGeneration.runAtomicTests(TestG1BarrierGeneration.java:886)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 7 more
at compiler.lib.ir_framework.test.TestVM.runTests(TestVM.java:901)
at compiler.lib.ir_framework.test.TestVM.start(TestVM.java:255)
at compiler.lib.ir_framework.test.TestVM.main(TestVM.java:168)
----
See attached jtr file.
The modified test passes on amd64:
==============================
Test summary
==============================
TEST TOTAL PASS FAIL ERROR SKIP
jtreg:test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java
1 1 0 0 0
==============================
Adding those:
-----
diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java b/test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java
index 01e015d50cb..297d1b848ce 100644
+++ b/test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java
@@ -879,6 +879,12 @@ public void runAtomicTests() {
Object oldVal2 = testCompareAndExchange(o, oldVal, newVal);
Asserts.assertEquals(oldVal, oldVal2);
Asserts.assertEquals(o.f, newVal);
+ // test failing compareAndExchange
+ Object newExpected = new Object();
+ Object newSetValue = new Object();
+ Object old = testCompareAndExchange(o, newExpected, newSetValue);
+ Asserts.assertEquals(newVal, old);
+ Asserts.assertEquals(o.f, newVal);
}
{
Outer o = new Outer();
@@ -888,6 +894,13 @@ public void runAtomicTests() {
boolean b = testCompareAndSwap(o, oldVal, newVal);
Asserts.assertTrue(b);
Asserts.assertEquals(o.f, newVal);
+ Object newSetValue = new Object();
+ Object old = testCompareAndExchange(o, newExpected, newSetValue);
+ Asserts.assertEquals(newVal, old);
+ Asserts.assertEquals(o.f, newVal);
}
{
Outer o = new Outer();
@@ -888,6 +894,13 @@ public void runAtomicTests() {
boolean b = testCompareAndSwap(o, oldVal, newVal);
Asserts.assertTrue(b);
Asserts.assertEquals(o.f, newVal);
+ // test failing compareAndSwap
+ Object newExpected = new Object();
+ Object newSetValue = new Object();
+ boolean failed = testCompareAndSwap(o, newExpected, newSetValue);
+ Asserts.assertFalse(failed);
+ Asserts.assertEquals(o.f, newVal);
+
}
{
----
makes the test fail on S390x platform:
----------
Test Failures (1)
-----------------
Custom Run Test: @Run: runAtomicTests - @Tests: {testCompareAndExchange,testCompareAndSwap,testGetAndSet,testCompareAndExchangeOnNewObject,testCompareAndSwapOnNewObject,testGetAndSetOnNewObject,testGetAndSetConditionallyOnNewObject,testGetAndSetOnNewObjectAfterException,testGetAndSetOnNewObjectAfterCall}:
compiler.lib.ir_framework.shared.TestRunException: There was an error while invoking @Run method public void compiler.gcbarriers.TestG1BarrierGeneration.runAtomicTests()
at compiler.lib.ir_framework.test.CustomRunTest.invokeTest(CustomRunTest.java:162)
at compiler.lib.ir_framework.test.AbstractTest.run(AbstractTest.java:105)
at compiler.lib.ir_framework.test.CustomRunTest.run(CustomRunTest.java:89)
at compiler.lib.ir_framework.test.TestVM.runTests(TestVM.java:865)
at compiler.lib.ir_framework.test.TestVM.start(TestVM.java:255)
at compiler.lib.ir_framework.test.TestVM.main(TestVM.java:168)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:119)
at java.base/java.lang.reflect.Method.invoke(Method.java:565)
at compiler.lib.ir_framework.test.CustomRunTest.invokeTest(CustomRunTest.java:159)
... 5 more
Caused by: java.lang.RuntimeException: assertEquals expected: java.lang.Object@460f76a6 but was: java.lang.Object@55f3c410
at jdk.test.lib.Asserts.fail(Asserts.java:715)
at jdk.test.lib.Asserts.assertEquals(Asserts.java:208)
at jdk.test.lib.Asserts.assertEquals(Asserts.java:195)
at compiler.gcbarriers.TestG1BarrierGeneration.runAtomicTests(TestG1BarrierGeneration.java:886)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
... 7 more
at compiler.lib.ir_framework.test.TestVM.runTests(TestVM.java:901)
at compiler.lib.ir_framework.test.TestVM.start(TestVM.java:255)
at compiler.lib.ir_framework.test.TestVM.main(TestVM.java:168)
----
See attached jtr file.
The modified test passes on amd64:
==============================
Test summary
==============================
TEST TOTAL PASS FAIL ERROR SKIP
jtreg:test/hotspot/jtreg/compiler/gcbarriers/TestG1BarrierGeneration.java
1 1 0 0 0
==============================
- backported by
-
JDK-8370576 [s390x] G1 barrier compareAndExchange does not return old value when compareExchange fails
-
- Resolved
-
- links to
-
Commit(master)
openjdk/jdk25u/5228b25b
-
Commit(master)
openjdk/jdk/5609ee11
-
Review(master)
openjdk/jdk25u/330
-
Review(master)
openjdk/jdk/27857