JDK-8351392 : C2 crash: failed: Expected Bool, but got OpaqueMultiversioning
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 25
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-03-07
  • Updated: 2025-03-10
  • Resolved: 2025-03-10
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 25
25 masterFixed
Related Reports
Causes :  
Relates :  
Relates :  
Description
This is a JavaFuzzer failure.

java -XX:CompileCommand=compileonly,*Test*::* -Xcomp -XX:PerMethodTrapLimit=0 Test.java

# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/oracle-work/jdk-fork7/open/src/hotspot/share/opto/loopopts.cpp:795), pid=416842, tid=416857
#  assert(false) failed: Expected Bool, but got OpaqueMultiversioning
#
# JRE version: Java(TM) SE Runtime Environment (25.0) (fastdebug build 25-internal-LTS-2025-03-06-1531074.emanuel...)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 25-internal-LTS-2025-03-06-1531074.emanuel..., compiled mode, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x13d1e56]  PhaseIdealLoop::conditional_move(Node*)+0x1066
#
# 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-fork7/build/linux-x64-debug/jdk/bin/core.416842)
#
# An error report file with more information is saved as:
# /oracle-work/jdk-fork7/build/linux-x64-debug/jdk/bin/hs_err_pid416842.log
#
# Compiler replay data is saved as:
# /oracle-work/jdk-fork7/build/linux-x64-debug/jdk/bin/replay_pid416842.log
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp

Comments
Changeset: 19b9f11c Branch: master Author: Emanuel Peter <epeter@openjdk.org> Date: 2025-03-10 09:44:42 +0000 URL: https://git.openjdk.org/jdk/commit/19b9f11c2ec37ef115c14adcfc31161786d46e95
10-03-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/23943 Date: 2025-03-07 10:35:58 +0000
07-03-2025

Here the relevant part of the loop: 167 OpaqueMultiversioning === _ 28 [[ 168 ]] #useless 5 Parm === 3 [[ 168 ]] Control !jvms: Reduced2::test @ bci:-1 (line 5) 168 If === 5 167 [[ 169 170 ]] P=0.999000, C=-1.000000 We see that we have a OpaqueMultiversioning that must have just been marked as useless. And that is below the multiversion_if, all loops have disappeared. 168 If === 5 167 [[ 169 170 ]] P=0.999000, C=-1.000000 169 IfTrue === 168 [[ 193 ]] #1 !orig=[252],[221],[194],[52] !jvms: Reduced2::test @ bci:14 (line 7) 170 IfFalse === 168 [[ 193 ]] #0 !orig=[192],[52] !jvms: Reduced2::test @ bci:14 (line 7) 193 Region === 193 170 169 [[ 193 58 195 ]] !orig=[52] !jvms: Reduced2::test @ bci:14 (line 7) 58 CallStaticJava === 193 6 7 8 9 (57 195 1 22 23 1 ) [[ 59 ]] # Static uncommon_trap(reason='unloaded' action='reinterpret' index='9' debug_id='0') void ( int ) C=0.000100 Reduced2::test @ bci:17 (line 8) !jvms: Reduced2::test @ bci:17 (line 8) 195 Phi === 193 172 10 [[ 58 ]] #long 59 Proj === 58 [[ 62 ]] #0 !jvms: Reduced2::test @ bci:17 (line 8) 62 Halt === 59 1 1 8 1 [[ 0 ]] !jvms: Reduced2::test @ bci:17 (line 8) The issue is that the loops just disappeared in the IGVN before this loop-opts round. Now we are marking the OpaqueMultiversioning useless, and before we actually remove it in IGVN, we now find it in PhaseIdealLoop::conditional_move during the same loop-opts phase as we marked it useless. I think we might just need to add an explicit exception to the condition / assert in PhaseIdealLoop::conditional_move.
07-03-2025

Reduced it a little more: java -XX:CompileCommand=dontinline,*::dontInline -XX:CompileCommand=compileonly,*Reduced*::test -XX:CompileCommand=printcompilation,*Reduced*::test -Xcomp -XX:PerMethodTrapLimit=0 -XX:+TraceLoopOpts Reduced2.java CompileCommand: dontinline *.dontInline bool dontinline = true CompileCommand: compileonly *Reduced*.test bool compileonly = true CompileCommand: PrintCompilation *Reduced*.test bool PrintCompilation = true 2213 88 b 3 Reduced2::test (52 bytes) 2214 89 b 4 Reduced2::test (52 bytes) Counted Loop: N125/N113 counted [12,376),+1 (-1 iters) sfpts={ 105 } Counted Loop: N134/N95 counted [1,4),+1 (-1 iters) Parallel IV: 79 Loop: N134/N95 counted [1,4),+1 (-1 iters) has_sfpt strip_mined Loop: N0/N0 has_sfpt Loop: N125/N113 counted [12,376),+1 (-1 iters) sfpts={ 105 } Loop: N133/N132 Loop: N134/N95 counted [1,4),+1 (-1 iters) has_sfpt strip_mined Empty with zero trip guard Loop: N134/N95 counted [1,4),+1 (-1 iters) has_sfpt strip_mined Parallel IV: 43 Loop: N125/N113 counted [12,376),+1 (-1 iters) sfpts={ 105 } Loop: N0/N0 has_sfpt Loop: N125/N113 counted [12,376),+1 (-1 iters) sfpts={ 105 } Multiversion Loop: N125/N113 counted [12,376),+1 (2147483648 iters) sfpts={ 105 } PreMainPost Loop: N125/N113 counted [12,376),+1 (2147483648 iters) multiversion_fast sfpts={ 105 } Unroll 2 Loop: N125/N113 counted [int,376),+1 (2147483648 iters) main multiversion_fast sfpts={ 105 } Loop: N0/N0 has_sfpt Loop: N183/N182 counted [12,376),+1 (2147483648 iters) rc multiversion_delayed_slow sfpts={ 180 } Loop: N243/N242 counted [12,int),+1 (4 iters) pre rc multiversion_fast sfpts={ 240 } Loop: N282/N113 counted [int,375),+2 (2147483648 iters) main rc multiversion_fast sfpts={ 279 } Loop: N210/N209 counted [int,376),+1 (4 iters) post rc multiversion_fast sfpts={ 207 } # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/oracle-work/jdk-fork7/open/src/hotspot/share/opto/loopopts.cpp:795), pid=536811, tid=536825 # assert(false) failed: Expected Bool, but got OpaqueMultiversioning ...
07-03-2025

Attached reduced test Reduced.java: $ java -XX:CompileCommand=dontinline,*::dontInline -XX:CompileCommand=compileonly,*Reduced*::* -Xcomp -XX:PerMethodTrapLimit=0 Reduced.java
07-03-2025

Also reproduces with only these flags: ./java -XX:CompileCommand=compileonly,Test::vMeth -XX:-TieredCompilation -Xcomp -XX:+UnlockExperimentalVMOptions -XX:PerMethodSpecTrapLimit=0 -XX:PerMethodTrapLimit=0 Test.java
07-03-2025

ILW = C2 assertion failure in spilt if, Java Fuzzer failure, -XX:-SplitIfBlocks = HLM = P3
07-03-2025