JDK-8338485 : C2: assert(bt == T_INT && _base == Int) failed: Not an Int
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19,21,23,24
  • Priority: P2
  • Status: Open
  • Resolution: Unresolved
  • OS: linux_ubuntu
  • CPU: x86_64
  • Submitted: 2024-08-04
  • Updated: 2024-08-20
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 24
24Unresolved
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
# JRE version: OpenJDK Runtime Environment (23.0) (fastdebug build 23-internal-adhoc.user.jdk23u)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 23-internal-adhoc.user.jdk23u, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)

A DESCRIPTION OF THE PROBLEM :
When running testcase with the jdk compiled from the source code downloaded from the jdk23u GitHub repo, the jdk crashes. The frequency of problem occurrence is approximately 8 times every 10 executions. jdk17u cannot reproduce this issue, and using the - XComp option cannot effectively and stably reproduce it.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac Test.java && java Test

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Exit after normal execution, no output
ACTUAL -
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/data/jdk23u/src/hotspot/share/opto/type.hpp:1962), pid=2662411, tid=2662425
#  assert((bt == T_INT && _base == Int) || (bt == T_LONG && _base == Long)) failed: Not an Int
#
# JRE version: OpenJDK Runtime Environment (23.0) (fastdebug build 23-internal-adhoc.jdk23u)
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 23-internal-adhoc.jdk23u, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x891b46]  ConstraintCastNode::optimize_integer_cast(PhaseGVN*, BasicType)+0x2e6
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /data/user/proj/toreport/352/reduce/core.2662411)
#
# An error report file with more information is saved as:
# /data/user/proj/toreport/352/reduce/hs_err_pid2662411.log
[thread 2662433 also had an error]
#
# Compiler replay data is saved as:
# /data/user/proj/toreport/352/reduce/replay_pid2662411.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#
timeout: the monitored command dumped core


---------- BEGIN SOURCE ----------
class Test {
  int a = 6;
  long b;
  int[] iArr9 = { 1, 2 };

  void f() {
    int o = -158;
    int j[] = new int[a];
    for (long e = 7; e < 91; ++e)
      b -= 0;
    for (int d = 3; d > -1; d--) {
      int i13 = d;
      try {
        for (int i0 = 5; i0 < 15; i0++) {
          for (int i11 = o - 1; i11 >= 0; i11--)
            d = iArr9[i11];
        }
      } finally {
        d = i13;
      }
      for (o = 0; o < 2; ++o) ;
    }
  }

  public static void main(String[] l) {
    try {
      Test m = new Test();
      for (int i = 0; i < 1000000; i++)
        m.f();
    } catch (Exception ex) {
    }
  }
}

---------- END SOURCE ----------


Comments
ILW = Assert / crash during C2 compilation, edge case but reproducible with release build, no known workaround but disable compilation of affected method = HMM = P2
20-08-2024

Relevant code was introduced by JDK-8288022 in JDK 20 but it also fails with JDK 19 (but not with earlier versions): # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/workspace/open/src/hotspot/share/opto/type.hpp:1825), pid=1339252, tid=1339275 # assert(_base == Int) failed: Not an Int # # JRE version: Java(TM) SE Runtime Environment (19.0.2+7) (fastdebug build 19.0.2+7-44) # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19.0.2+7-44, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64) # Problematic frame: # V [libjvm.so+0x9508a7] CastIINode::Ideal(PhaseGVN*, bool)+0xb7 Current CompileTask: C2: 836 1343 ! 4 Test::f (124 bytes) Stack: [0x00007d72aecfe000,0x00007d72aedfe000], sp=0x00007d72aedf8480, free space=1001k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x9508a7] CastIINode::Ideal(PhaseGVN*, bool)+0xb7 V [libjvm.so+0x17f4618] PhaseIterGVN::transform_old(Node*)+0xb8 V [libjvm.so+0x17ede6e] PhaseIterGVN::optimize()+0x6e V [libjvm.so+0xb0681a] PhaseIdealLoop::optimize(PhaseIterGVN&, LoopOptsMode)+0x65a V [libjvm.so+0xb02c67] Compile::Optimize()+0x1027 V [libjvm.so+0xb04df0] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1520 V [libjvm.so+0x91c04a] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x62a V [libjvm.so+0xb13958] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xbb8 V [libjvm.so+0xb14948] CompileBroker::compiler_thread_loop()+0x6f8 V [libjvm.so+0x1aa4818] JavaThread::thread_main_inner()+0x238 V [libjvm.so+0x1aafd90] Thread::call_run()+0x100 V [libjvm.so+0x1760c34] thread_native_entry(Thread*)+0x104 We get a SIGSEGV in product: # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x0000732a22c98a3b, pid=1339618, tid=1339641 # # JRE version: Java(TM) SE Runtime Environment (21.0.4+3) (build 21.0.4-ea+3-LTS-234) # Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0.4-ea+3-LTS-234, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64) # Problematic frame: # V [libjvm.so+0xc98a3b] Node::unique_ctrl_out() const+0xb Current CompileTask: C2: 267 1388 ! 4 Test::f (124 bytes) Stack: [0x00007329f2f00000,0x00007329f3000000], sp=0x00007329f2ffb330, free space=1004k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0xc98a3b] Node::unique_ctrl_out() const+0xb V [libjvm.so+0xb7b7b8] PhaseIdealLoop::update_main_loop_assertion_predicates(Node*, CountedLoopNode*, Node*, int)+0x118 V [libjvm.so+0xb80fb7] PhaseIdealLoop::do_unroll(IdealLoopTree*, Node_List&, bool)+0x1e7 V [libjvm.so+0xb87c36] IdealLoopTree::iteration_split_impl(PhaseIdealLoop*, Node_List&)+0x5d6 V [libjvm.so+0xb87df9] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x159 V [libjvm.so+0xb87cce] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x2e V [libjvm.so+0xba0543] PhaseIdealLoop::build_and_optimize()+0x983 V [libjvm.so+0x645dca] Compile::Optimize()+0xb0a V [libjvm.so+0x647996] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0xf26 V [libjvm.so+0x574d2d] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x17d V [libjvm.so+0x64d7b7] CompileBroker::invoke_compiler_on_method(CompileTask*)+0xa97 V [libjvm.so+0x6508a8] CompileBroker::compiler_thread_loop()+0x6a8 V [libjvm.so+0x8fd8f8] JavaThread::thread_main_inner() [clone .part.0]+0xb8 V [libjvm.so+0xea7f98] Thread::call_run()+0xa8 V [libjvm.so+0xccaf2a] thread_native_entry(Thread*)+0xda
20-08-2024

Starts to work after JDK-8334647 which sets additionally sets the control input of some CastII nodes. I'm not sure if this just hides the problem hit with this reproducer or if it really is the bug fix. We should double check this if it's a dup or something separate. I'll have a look.
16-08-2024

Reply from Submitter ================ I have updated to the latest version of the JDK (compiled from the code downloaded from the JDK repository on GitHub), and the issue can no longer be reproduced. openjdk version "24-internal" 2025-03-18 OpenJDK Runtime Environment (fastdebug build 24-internal-adhoc.xiezf.jdk23u) OpenJDK 64-Bit Server VM (fastdebug build 24-internal-adhoc.xiezf.jdk23u, mixed mode) Reply to submitter ================ Oracle JDK 23 is still not public. Thanks to hear that the crash doesn't happen on openjdk version "24-internal" 2025-03-18.
16-08-2024