-
Bug
-
Resolution: Fixed
-
P2
-
8, 11, 16, 17, 18
-
b18
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8275093 | 17.0.2 | Tobias Hartmann | P2 | Closed | Fixed | b03 |
JDK-8275042 | 11.0.14-oracle | Tobias Hartmann | P2 | Closed | Fixed | b02 |
JDK-8275198 | 11.0.14 | Martin Doerr | P2 | Resolved | Fixed | b01 |
JDK-8295330 | openjdk8u362 | Yuri Nesterenko | P2 | Resolved | Fixed | b01 |
# Java version
java version "16.0.2" 2021-07-20
Java(TM) SE Runtime Environment (build 16.0.2+7-67)
Java HotSpot(TM) 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)
# Operating system details
$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.2 LTS"
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$ uname -a
Linux zzq-ThinkPad-T470 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Different outputs of the attached program are observed between different compilation tiers. This bug affects Oracle 1.8.0_301, 11.0.12, 16.0.2 and early access build 17-ea+32-2679 and 18-ea+7-288.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
# Compile
$ javac C.java
# Default or compilation up to level 4
$ java C
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
10000
ACTUAL -
# Non-deterministic
5597
---------- BEGIN SOURCE ----------
# C.java
(Attached.)
public class C {
static String m() {
StringBuilder sb = new StringBuilder(-1);
return sb.toString();
}
public static void main(String[] args) {
int sum = 0;
for (int i = 0; i < 10_000; ++i) {
try {
m();
} catch (Throwable e) {
sum += 1;
}
}
System.out.println(sum); // should be 10_000
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
# Compilation up to level 1
$ java -XX:TieredStopAtLevel=1 C
# Output (correct)
10000
# Interpreter or compilation up to level 0
$ java -Xint C
# Output (correct)
10000
FREQUENCY : always
- backported by
-
JDK-8275198 C2: Missing NegativeArraySizeException when creating StringBuilder with negative capacity
- Resolved
-
JDK-8295330 C2: Missing NegativeArraySizeException when creating StringBuilder with negative capacity
- Resolved
-
JDK-8275042 C2: Missing NegativeArraySizeException when creating StringBuilder with negative capacity
- Closed
-
JDK-8275093 C2: Missing NegativeArraySizeException when creating StringBuilder with negative capacity
- Closed
- relates to
-
JDK-8295322 Tests for JDK-8271459 were not backported to 11u
- Resolved
- links to
-
Commit openjdk/jdk8u-dev/dfeeceb2
-
Commit openjdk/jdk11u-dev/844c504b
-
Commit openjdk/jdk17u/1cc972f3
-
Commit openjdk/jdk/3953e077
-
Review openjdk/jdk8u-dev/111
-
Review openjdk/jdk11u-dev/510
-
Review openjdk/jdk17u/177
-
Review openjdk/jdk/5652