JDK-8251535 : Partial peeling at unsigned test adds incorrect loop exit check
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 8u251,9,10,11,12,13,14,15,16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: x86_64
  • Submitted: 2020-08-12
  • Updated: 2024-12-09
  • Resolved: 2020-10-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 16
11.0.10Fixed 16 b21Fixed
Related Reports
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
OpenJDK 11 and 14 allow to reproduce this bug, GraalVM does not.

A DESCRIPTION OF THE PROBLEM :
The first integer printed is not in the range specified by if-statement. 

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Just run the main() method and check the output.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
#1 {integer in the range from 1000 to 9999 (both sides including)}
#2 {integer in the range from 1000 to 9999 (both sides including)}
ACTUAL -
#1 {integer NOT in the range from 1000 to 9999 (both sides including)}
#2 {integer in the range from 1000 to 9999 (both sides including)}

---------- BEGIN SOURCE ----------
public class Bug {
    /*
    * Why does this code output:
    * #1 1746077296
    * #2 9296
    * ???
    * */
    public static void main(String[] args) {
        for (int i = 0, j = 0; j < 2; i -= 1000) {
            if ((i > 999) && (i < 10000)) {
                j++;
                System.out.println("#" + j + ' ' + i + ' ' + Integer.MAX_VALUE);
            }
        }
    }
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use -XX:TieredStopAtLevel=3 option  or make counter i and j volatile class fields.

FREQUENCY : always



Comments
Fix Request (11u) Fixes a compiler bug and keeps codebases in sync (I see 11.0.11-oracle). Patch applies cleanly to 11u, new test fails without the patch, passes with it. Patched JDK passes tier{1,2}.
13-11-2020

Changeset: 7c0d4170 Author: Tobias Hartmann <thartmann@openjdk.org> Date: 2020-10-16 06:25:33 +0000 URL: https://git.openjdk.java.net/jdk/commit/7c0d4170
16-10-2020

-XX:-PartialPeelAtUnsignedTests is a less intrusive workaround
15-10-2020

ILW = Incorrect execution of C2 compiled code, easy to reproduce but a long standing issue and not a recent regression, -XX:-PartialPeelLoop or disable compilation of affected method = HLM = P3
13-08-2020

Issue is reproduced. OS: Windows 10 JDK 8 :Fail JDK 11:Fail JDK 14:Fail JDK 15ea34: Fail JDK 16ea9: Fail In all the above cases the first output is not in the range of 1000-9999 and it varies on each round of compilation Output: #1 1762502296 2147483647 #2 9296 2147483647 While on GraalVM the output is always same and in the range 1000-9999 #1 9296 2147483647 #2 8296 2147483647 Used (openjdk version "1.8.0_262" and OpenJDK 64-Bit GraalVM CE 19.3.3)
13-08-2020