-
Bug
-
Resolution: Fixed
-
P2
-
23, 24
-
b05
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8336131 | 23.0.1 | Emanuel Peter | P2 | Resolved | Fixed | b03 |
JDK-8335394 | 23 | Emanuel Peter | P2 | Resolved | Fixed | b30 |
With Unsafe, you can create arbitrary array pointers, and some of them seem to lead to wrong results with the MergeStores optimization JDK-8318446.
The easiest way for now is to disable Unsafe accesses, and then redesign the ArrayPointer class from the ground up, to be more powerful and safe in all cases (incl proofs).JDK-8335392
./java --add-modules java.base --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.util=ALL-UNNAMED -XX:CompileCommand=compileonly,TestMergeStores*::test* -XX:CompileCommand=printcompilation,TestMergeStores*::test* -Xbatch -XX:+TraceMergeStores -XX:+MergeStores TestMergeStoresUnsafeArrayPointer.java
CompileCommand: compileonly TestMergeStores*.test* bool compileonly = true
CompileCommand: PrintCompilation TestMergeStores*.test* bool PrintCompilation = true
Allocate big array of SIZE = 1073741924
test1
7583 99 b 3 TestMergeStoresUnsafeArrayPointer::testClear (72 bytes)
7585 100 b 3 TestMergeStoresUnsafeArrayPointer::testSum (84 bytes)
7586 101 % b 4 TestMergeStoresUnsafeArrayPointer::testClear @ 2 (72 bytes)
7612 102 b 4 TestMergeStoresUnsafeArrayPointer::testClear (72 bytes)
7651 103 % b 4 TestMergeStoresUnsafeArrayPointer::testSum @ 4 (84 bytes)
7674 104 b 4 TestMergeStoresUnsafeArrayPointer::testSum (84 bytes)
7695 105 b 3 TestMergeStoresUnsafeArrayPointer::test1 (38 bytes)
7696 106 b 4 TestMergeStoresUnsafeArrayPointer::test1 (38 bytes)
[TraceMergeStores]: Replace
54 StoreI === 41 7 52 32 [[ 63 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=4; unsafe Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=4; !jvms: TestMergeStoresUnsafeArrayPointer::test1 @ bci:20 (line 81)
63 StoreI === 41 54 61 58 [[ 18 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=4; unsafe Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=4; !jvms: TestMergeStoresUnsafeArrayPointer::test1 @ bci:34 (line 82)
[TraceMergeStores]: with
66 ConL === 0 [[ 67 ]] #long:7378697628877472322
67 StoreL === 41 7 52 66 [[ ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=4; mismatched Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=4;
test2
7720 107 b 3 TestMergeStoresUnsafeArrayPointer::test2 (55 bytes)
7722 108 b 4 TestMergeStoresUnsafeArrayPointer::test2 (55 bytes)
[TraceMergeStores]: Replace
63 StoreI === 51 7 61 42 [[ 78 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: TestMergeStoresUnsafeArrayPointer::test2 @ bci:30 (line 87)
78 StoreI === 51 63 76 73 [[ 18 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: TestMergeStoresUnsafeArrayPointer::test2 @ bci:51 (line 88)
[TraceMergeStores]: with
81 ConL === 0 [[ 82 ]] #long:7378697628877472322
82 StoreL === 51 7 61 81 [[ ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; mismatched Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5;
ERROR: test2 had wrong value: 216504268185 != 217578010009
Exception in thread "main" java.lang.RuntimeException: ERRORS: 1
at TestMergeStoresUnsafeArrayPointer.main(TestMergeStoresUnsafeArrayPointer.java:60)
The easiest way for now is to disable Unsafe accesses, and then redesign the ArrayPointer class from the ground up, to be more powerful and safe in all cases (incl proofs).
./java --add-modules java.base --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-exports java.base/jdk.internal.util=ALL-UNNAMED -XX:CompileCommand=compileonly,TestMergeStores*::test* -XX:CompileCommand=printcompilation,TestMergeStores*::test* -Xbatch -XX:+TraceMergeStores -XX:+MergeStores TestMergeStoresUnsafeArrayPointer.java
CompileCommand: compileonly TestMergeStores*.test* bool compileonly = true
CompileCommand: PrintCompilation TestMergeStores*.test* bool PrintCompilation = true
Allocate big array of SIZE = 1073741924
test1
7583 99 b 3 TestMergeStoresUnsafeArrayPointer::testClear (72 bytes)
7585 100 b 3 TestMergeStoresUnsafeArrayPointer::testSum (84 bytes)
7586 101 % b 4 TestMergeStoresUnsafeArrayPointer::testClear @ 2 (72 bytes)
7612 102 b 4 TestMergeStoresUnsafeArrayPointer::testClear (72 bytes)
7651 103 % b 4 TestMergeStoresUnsafeArrayPointer::testSum @ 4 (84 bytes)
7674 104 b 4 TestMergeStoresUnsafeArrayPointer::testSum (84 bytes)
7695 105 b 3 TestMergeStoresUnsafeArrayPointer::test1 (38 bytes)
7696 106 b 4 TestMergeStoresUnsafeArrayPointer::test1 (38 bytes)
[TraceMergeStores]: Replace
54 StoreI === 41 7 52 32 [[ 63 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=4; unsafe Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=4; !jvms: TestMergeStoresUnsafeArrayPointer::test1 @ bci:20 (line 81)
63 StoreI === 41 54 61 58 [[ 18 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=4; unsafe Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=4; !jvms: TestMergeStoresUnsafeArrayPointer::test1 @ bci:34 (line 82)
[TraceMergeStores]: with
66 ConL === 0 [[ 67 ]] #long:7378697628877472322
67 StoreL === 41 7 52 66 [[ ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=4; mismatched Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=4;
test2
7720 107 b 3 TestMergeStoresUnsafeArrayPointer::test2 (55 bytes)
7722 108 b 4 TestMergeStoresUnsafeArrayPointer::test2 (55 bytes)
[TraceMergeStores]: Replace
63 StoreI === 51 7 61 42 [[ 78 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: TestMergeStoresUnsafeArrayPointer::test2 @ bci:30 (line 87)
78 StoreI === 51 63 76 73 [[ 18 ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5; unsafe Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; !jvms: TestMergeStoresUnsafeArrayPointer::test2 @ bci:51 (line 88)
[TraceMergeStores]: with
81 ConL === 0 [[ 82 ]] #long:7378697628877472322
82 StoreL === 51 7 61 81 [[ ]] @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5; mismatched Memory: @int[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, idx=5;
ERROR: test2 had wrong value: 216504268185 != 217578010009
Exception in thread "main" java.lang.RuntimeException: ERRORS: 1
at TestMergeStoresUnsafeArrayPointer.main(TestMergeStoresUnsafeArrayPointer.java:60)
- backported by
-
JDK-8335394 C2 MergeStores: wrong result with Unsafe
- Resolved
-
JDK-8336131 C2 MergeStores: wrong result with Unsafe
- Resolved
- relates to
-
JDK-8335392 C2 MergeStores: enhanced pointer parsing
- Resolved
-
JDK-8318446 C2: optimize stores into primitive arrays by combining values into larger store
- Resolved
- links to
-
Commit openjdk/jdk/272d11a3
-
Commit openjdk/jdk/9046d7ae
-
Review openjdk/jdk/19964
-
Review(jdk23) openjdk/jdk/19985
(3 links to)