JDK-8273139 : C2: assert(f <= 1 && f >= 0) failed: Incorrect frequency
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,18,19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2021-08-30
  • Updated: 2022-07-25
  • Resolved: 2022-01-19
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 17 JDK 18 JDK 19
17.0.4-oracleFixed 18.0.1Fixed 19 b07Fixed
Related Reports
Relates :  
Description
The attached testcase fails with the following assertion:

To reproduce:
$ java -Xcomp -XX:CompileOnly=Test Test.java
$ java -Xcomp -XX:CompileOnly=Reduced Reduced.java

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/ff806ead-2cac-495d-9cbc-62116f99bf14-S13890/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/e1985841-cb1f-4767-b2e4-927825614993/runs/9fce6d83-2b2c-4178-b4c4-97cbe003ff2d/workspace/open/src/hotspot/share/opto/loopPredicate.cpp:888), pid=18540, tid=18553
#  assert(f <= 1 && f >= 0) failed: Incorrect frequency
#
# JRE version: Java(TM) SE Runtime Environment (17.0+35) (fastdebug build 17+35-LTS-2724)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 17+35-LTS-2724, compiled mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x12df66d]  PathFrequency::to(Node*)+0xc2d
..........
Command Line: -Xmx1G -Xcomp -Xbatch -XX:CompileOnly=Test -XX:CompileCommand=quiet Test
..........
Current thread (0x00007fa02c4821a0):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=18553, stack(0x00007fa0056ff000,0x00007fa005800000)]


Current CompileTask:
C2:   1524   71   !b  4       Test::mainTest (2044 bytes)

Stack: [0x00007fa0056ff000,0x00007fa005800000],  sp=0x00007fa0057f9d60,  free space=1003k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x12df66d]  PathFrequency::to(Node*)+0xc2d
V  [libjvm.so+0x12da934]  PhaseIdealLoop::loop_predication_follow_branches(Node*, IdealLoopTree*, float, PathFrequency&, Node_Stack&, VectorSet&, Node_List&)+0x574
V  [libjvm.so+0x12dbd12]  PhaseIdealLoop::loop_predication_impl(IdealLoopTree*) [clone .part.0]+0x1192
V  [libjvm.so+0x12dc259]  IdealLoopTree::loop_predication(PhaseIdealLoop*)+0x109
V  [libjvm.so+0x12dc195]  IdealLoopTree::loop_predication(PhaseIdealLoop*)+0x45
V  [libjvm.so+0x12dc195]  IdealLoopTree::loop_predication(PhaseIdealLoop*)+0x45
V  [libjvm.so+0x12dc178]  IdealLoopTree::loop_predication(PhaseIdealLoop*)+0x28
V  [libjvm.so+0x12dc195]  IdealLoopTree::loop_predication(PhaseIdealLoop*)+0x45
V  [libjvm.so+0x12dc195]  IdealLoopTree::loop_predication(PhaseIdealLoop*)+0x45
V  [libjvm.so+0x12dc195]  IdealLoopTree::loop_predication(PhaseIdealLoop*)+0x45
V  [libjvm.so+0x132487f]  PhaseIdealLoop::build_and_optimize(LoopOptsMode)+0x11cf
V  [libjvm.so+0xa377da]  PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x2da
V  [libjvm.so+0xa340f5]  Compile::Optimize()+0x14f5
V  [libjvm.so+0xa35c78]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, bool, DirectiveSet*)+0x1618
V  [libjvm.so+0x84b116]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x646
V  [libjvm.so+0xa45cc1]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xb71
V  [libjvm.so+0xa46968]  CompileBroker::compiler_thread_loop()+0x5a8
V  [libjvm.so+0x18dca01]  JavaThread::thread_main_inner()+0x271
V  [libjvm.so+0x18e3ff0]  Thread::call_run()+0x100
V  [libjvm.so+0x15a9cf4]  thread_native_entry(Thread*)+0x104
Comments
Fix Request (17u): Should get backported for parity with 17.0.4-oracle. Applies cleanly. Nightly tests have passed.
15-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk17u-dev/pull/252 Date: 2022-03-14 15:05:38 +0000
14-03-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk18u/pull/14 Date: 2022-02-01 10:27:20 +0000
01-02-2022

Fix Request (JDK 18u) The fix has already been backported to JDK 17u and should be backported to JDK 18u as well to avoid a regression. The fix is low risk and applies cleanly. It has been tested manually with tier1-3 and in the JDK 17u and JDK 19 CI.
01-02-2022

Changeset: 68b40ec2 Author: Emanuel Peter <emanuel.peter@oracle.com> Committer: Tobias Hartmann <thartmann@openjdk.org> Date: 2022-01-19 11:47:17 +0000 URL: https://git.openjdk.java.net/jdk/commit/68b40ec28658a2dd829c77281b0025e16095c170
19-01-2022

A pull request was submitted for review. URL: https://git.openjdk.java.net/jdk/pull/7113 Date: 2022-01-17 14:27:48 +0000
18-01-2022

Bug does not manifest any more since change 83b2219220266c1365466970d08606fef766c4fa. However, it is still there, just does not get triggered any more. The bug is caused by incorrect rounding (many float operations are not rounded properly). The exact "f <= 1" check can fail in some occasions, if the sum of probabilities slightly exceeds 1, due to these rounding issues.
17-01-2022

ILW = Assertion failure in C2 loop predication likely due to some rounding errors (should be harmless in product), only with single JavaFuzzer test, disable compilation of affected method or use -XX:-UseLoopPredicate = HLM = P3
30-08-2021