Details
-
Bug
-
Resolution: Fixed
-
P3
-
9, 11, 17, 18, 19, 20, 21
-
b07
-
generic
-
generic
Backports
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8307025 | 20u-cpu | Tobias Hartmann | P3 | Resolved | Fixed | master |
JDK-8305546 | 20.0.2 | Tobias Hartmann | P3 | Resolved | Fixed | b03 |
JDK-8301955 | 17.0.8-oracle | Tobias Hartmann | P3 | Resolved | Fixed | b01 |
JDK-8306513 | 17.0.8 | Goetz Lindenmaier | P3 | Resolved | Fixed | b01 |
JDK-8309487 | 11.0.21 | Goetz Lindenmaier | P3 | Resolved | Fixed | b01 |
JDK-8301948 | 11.0.20-oracle | Tobias Hartmann | P3 | Resolved | Fixed | b01 |
Description
# Java version
java 19.0.1 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)
# Operating system details
$ cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.5 LTS"
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.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=bionic
UBUNTU_CODENAME=bionic
$ uname -a
Linux seoul 5.4.0-99-generic #112~18.04.1-Ubuntu SMP Thu Feb 3 14:09:57 UTC 2022 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 java 11.0.17 2022-10-18, java 17 2021-09-14 LTS, Oracle JDK 18.0.2.1, Oracle JDK 19.0.1, and openjdk 20-ea 2023-03-21. It was not reproduced in java version "1.8.0_351".
REGRESSION : Last worked in version 8u351
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The following steps shows how to reproduce the bug on Java 19.0.1 in a
Ubuntu Linux environment.
# Compile
$ javac C.java
# Default or compilation up to level 4
$ java C
# Output (incorrect)
99997
# Compilation up to level 1
$ java -XX:TieredStopAtLevel=1 C
# Output (correct)
100000
# Interpreter or compilation up to level 0
$ java -Xint C
# Output (correct)
100000
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
100000
ACTUAL -
99997
---------- BEGIN SOURCE ----------
public class C {
static byte[] m(byte[] arg1) {
byte[] b = new byte[-1];
System.arraycopy(arg1, 0, b, 0, arg1.length);
return b;
}
public static void main(String[] args) {
int count = 0;
for (int i = 0; i < 100_000; ++i) {
try {
System.out.println(m(null));
} catch (Throwable e) {
if (e instanceof java.lang.NegativeArraySizeException) {
count++;
}
}
}
System.out.println(count); // Should be 100_000
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Interpreter or compilation for Level 0, 1, 2, 3 are fine.
$ java -XX:TieredStopAtLevel=3 C
FREQUENCY : always
Attachments
Issue Links
- backported by
-
JDK-8301948 C2: Arraycopy intrinsic throws incorrect exception
- Resolved
-
JDK-8301955 C2: Arraycopy intrinsic throws incorrect exception
- Resolved
-
JDK-8305546 C2: Arraycopy intrinsic throws incorrect exception
- Resolved
-
JDK-8306513 C2: Arraycopy intrinsic throws incorrect exception
- Resolved
-
JDK-8307025 C2: Arraycopy intrinsic throws incorrect exception
- Resolved
-
JDK-8309487 C2: Arraycopy intrinsic throws incorrect exception
- Resolved
- duplicates
-
JDK-8301660 Incorrect Array Exception Thrown with c2
- Closed
- relates to
-
JDK-8073866 Fix for 8064703 is not sufficient
- Resolved
- links to
-
Commit openjdk/jdk11u-dev/d917caaf
-
Commit openjdk/jdk17u-dev/0ca8d00f
-
Commit openjdk/jdk20u/aa6d177a
-
Commit openjdk/jdk/5a478ef7
-
Review openjdk/jdk11u-dev/1926
-
Review openjdk/jdk17u-dev/1270
-
Review openjdk/jdk20u/31
-
Review openjdk/jdk/12120