-
Bug
-
Resolution: Fixed
-
P2
-
11, 12
-
Ampere
-
b22
-
aarch64
-
linux
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8256598 | 11.0.11-oracle | Dukebot | P2 | Closed | Fixed | b01 |
JDK-8230195 | 11.0.5 | Dmitrij Pochepko | P2 | Resolved | Fixed | b05 |
The test stnippet IndexOfTest listed below fails the StringBuilder.indexOf after some time on AArch64 JDK12.
Expected value is -1 but after some time it returns 256.
Excluding java.lang.String.indexOf from compilation makes the test successful.
This error is observed on JDK12 revision: 6e8c8d16ecb4 and AdoptOpenJDK version 11.0.1+13
Commandline error case:
[sanzinger@... compiler]$ ~/jdk/jdk12-6e8c8d16ecb4/build/linux-aarch64-server-release/jdk/bin/java -XX:-Inline -Xcomp -cp . IndexOfTest
ERROR: Expected offset -1, got 256
Commandline success case (exclude String.indexOf from compilation):
[sanzinger@... compiler]$ ~/jdk/jdk12-6e8c8d16ecb4/build/linux-aarch64-server-release/jdk/bin/java -XX:-Inline -XX:CompileCommand=exclude,java.lang.String::indexOf -Xcomp -cp . IndexOfTest
CompileCommand: exclude java/lang/String.indexOf
Test was successful
public class IndexOfTest {
public static final String sourceString = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata ";
public static final String constantString = sourceString.substring(50, 50 + 64);
public static final StringBuilder sb;
static {
sb = new StringBuilder(sourceString);
sb.append(constantString);
sb.setLength(sourceString.length());
}
public static void main(String[] argv) {
for(int i = 0; i < 2000; i++) {
testStringBuilderIndexOfConstantOffset();
}
System.out.println("Test was successful");
}
public static void testStringBuilderIndexOfConstantOffset() {
int off = testStringBuilderIndexOfOffset(sb, constantString, Math.max(0, sourceString.length() - constantString.length()));
if(off != -1) {
System.out.println("ERROR: Expected offset -1, got " + off);
System.exit(1);
}
}
public static int testStringBuilderIndexOfOffset(StringBuilder a, String b, int fromIndex) {
return a.indexOf(b, fromIndex);
}
}
Expected value is -1 but after some time it returns 256.
Excluding java.lang.String.indexOf from compilation makes the test successful.
This error is observed on JDK12 revision: 6e8c8d16ecb4 and AdoptOpenJDK version 11.0.1+13
Commandline error case:
[sanzinger@... compiler]$ ~/jdk/jdk12-6e8c8d16ecb4/build/linux-aarch64-server-release/jdk/bin/java -XX:-Inline -Xcomp -cp . IndexOfTest
ERROR: Expected offset -1, got 256
Commandline success case (exclude String.indexOf from compilation):
[sanzinger@... compiler]$ ~/jdk/jdk12-6e8c8d16ecb4/build/linux-aarch64-server-release/jdk/bin/java -XX:-Inline -XX:CompileCommand=exclude,java.lang.String::indexOf -Xcomp -cp . IndexOfTest
CompileCommand: exclude java/lang/String.indexOf
Test was successful
public class IndexOfTest {
public static final String sourceString = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata ";
public static final String constantString = sourceString.substring(50, 50 + 64);
public static final StringBuilder sb;
static {
sb = new StringBuilder(sourceString);
sb.append(constantString);
sb.setLength(sourceString.length());
}
public static void main(String[] argv) {
for(int i = 0; i < 2000; i++) {
testStringBuilderIndexOfConstantOffset();
}
System.out.println("Test was successful");
}
public static void testStringBuilderIndexOfConstantOffset() {
int off = testStringBuilderIndexOfOffset(sb, constantString, Math.max(0, sourceString.length() - constantString.length()));
if(off != -1) {
System.out.println("ERROR: Expected offset -1, got " + off);
System.exit(1);
}
}
public static int testStringBuilderIndexOfOffset(StringBuilder a, String b, int fromIndex) {
return a.indexOf(b, fromIndex);
}
}
- backported by
-
JDK-8230195 AArch64: String.indexOf generates incorrect result
- Resolved
-
JDK-8256598 AArch64: String.indexOf generates incorrect result
- Closed
- relates to
-
JDK-8189103 AARCH64: optimize String indexOf intrinsic
- Resolved