JDK-8351645 : C2: Assertion failures in Expand/CompressBits idealizations with TOP
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19,21,24,25,26
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-03-11
  • Updated: 2025-06-19
  • Resolved: 2025-06-17
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 26
26 b03Fixed
Related Reports
Causes :  
Description
I found this with the Template Framework JDK-8344942.

It seems that ExpandBitsNode::Ideal does not handle TOP inputs well, see the graph at the time of the assert:

   2   249  ConI  === 0  [[ 315 426 500 572 856 900 907 964 973 982 989 ]]  #int:38
   2     0  Root  === 0 64 82 93 754 806 264 237 180 281 673 777 725 702  [[ 0 1 3 20 276 24 275 29 38 41 249 59 72 77 88 811 292 245 138 148 149 175 181 185 190 207 843 845 847 881 886 888 943 945 948 950 952 1038 1039 1043 1045 1046 1049 1081 1101 1103 1106 1111 1128 ]] 
   1   426  LShiftL  === _ 1 249  [[ 425 ]]  !orig=315,[248] !jvms: Test::test @ bci:35 (line 24)
   1     1  Con  === 0  [[ ]]  #top
   0   425  ExpandBits  === _ 1 426  [[ 487 ]]  #long !orig=314,250 !jvms: Test::test @ bci:43 (line 25)

It is not intermittent, but might be in older versions, at least with StressIGVN it becomes intermittent.

java -Xbatch -XX:CompileCommand=compileonly,Test::test* -XX:+StressIGVN -XX:RepeatCompilation=100 Test.java

CompileCommand: compileonly Test.test* bool compileonly = true
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/oracle-work/jdk-fork0/open/src/hotspot/share/opto/type.hpp:2015), pid=1531073, tid=1531087
#  assert(_base == Long) failed: Not a Long
#
# JRE version: Java(TM) SE Runtime Environment (25.0) (fastdebug build 25-internal-LTS-2025-03-11-0926490.emanuel...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-internal-LTS-2025-03-11-0926490.emanuel..., mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xf3000e]  ExpandBitsNode::Ideal(PhaseGVN*, bool)+0x10ce
#
# 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 /oracle-work/jdk-fork0/build/linux-x64-debug/jdk/bin/core.1531073)
#
# An error report file with more information is saved as:
# /oracle-work/jdk-fork0/build/linux-x64-debug/jdk/bin/hs_err_pid1531073.log
#
# Compiler replay data is saved as:
# /oracle-work/jdk-fork0/build/linux-x64-debug/jdk/bin/replay_pid1531073.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#
Aborted (core dumped)

Current CompileTask:
C2:2357   91 %  b  4       Test::test @ 8 (55 bytes)

Stack: [0x000075192c800000,0x000075192c900000],  sp=0x000075192c8fb160,  free space=1004k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xf3000e]  ExpandBitsNode::Ideal(PhaseGVN*, bool)+0x10ce  (type.hpp:2015)
V  [libjvm.so+0x168365d]  PhaseIterGVN::transform_old(Node*)+0xbd  (phaseX.cpp:668)
V  [libjvm.so+0x1679034]  PhaseIterGVN::optimize()+0x94  (phaseX.cpp:1046)
V  [libjvm.so+0xa7b864]  Compile::process_for_post_loop_opts_igvn(PhaseIterGVN&)+0x124  (compile.cpp:1869)
V  [libjvm.so+0xa811bf]  Compile::Optimize()+0xd2f  (compile.cpp:2481)   
V  [libjvm.so+0xa8420f]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x1ecf  (compile.cpp:858)
V  [libjvm.so+0x8c3d00]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x440  (c2compiler.cpp:141)
V  [libjvm.so+0xa91d7a]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xc8a  (compileBroker.cpp:2338)
V  [libjvm.so+0xa92c28]  CompileBroker::compiler_thread_loop()+0x598  (compileBroker.cpp:1975)
V  [libjvm.so+0xf7eb0f]  JavaThread::thread_main_inner()+0x12f  (javaThread.cpp:776)
V  [libjvm.so+0x1947b56]  Thread::call_run()+0xb6  (thread.cpp:231)
V  [libjvm.so+0x15fa1b8]  thread_native_entry(Thread*)+0x128  (os_linux.cpp:877)
C  [libc.so.6+0x9caa4]
Comments
Changeset: ff75f763 Branch: master Author: Jatin Bhateja <jbhateja@openjdk.org> Date: 2025-06-17 07:16:19 +0000 URL: https://git.openjdk.org/jdk/commit/ff75f763c0a91534ab593a43e2ace741d05b0ccb
17-06-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/25586 Date: 2025-06-02 11:53:23 +0000
02-06-2025

I'm tentatively deferring this to JDK 26 since it's an old issue and we are getting closer to RDP 1 (June 05, 2025). [~jbhateja] feel free to still fix this in JDK 25 if there's time.
13-05-2025

[~jbhateja], could you please have a look?
11-03-2025

Reproduces since JDK 19, looks like a regression from JDK-8283894. Workaround "-XX:DisableIntrinsic=_expand_l". ILW = Assert during C2 compilation, easy to reproduce but edge case, -XX:DisableIntrinsic=_expand_l = HLM = P3
11-03-2025