JDK-8273165 : GraphKit::combine_exception_states fails with "matching stack sizes" assert
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 17,18
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2021-08-31
  • Updated: 2022-02-04
  • Resolved: 2021-09-02
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
17.0.2Fixed 18 b14Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
We started hitting this a lot in Valhalla but I noticed that it also triggers in the mainline CI:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/workspace/open/src/hotspot/share/opto/graphKit.cpp:348), pid=6599, tid=6615
#  assert(ex_jvms->sp() == phi_map->_jvms->sp()) failed: matching stack sizes
#
# JRE version: Java(TM) SE Runtime Environment (18.0+13) (fastdebug build 18-ea+13-623)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 18-ea+13-623, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xd43e36]  GraphKit::combine_exception_states(SafePointNode*, SafePointNode*) [clone .part.0]+0xc6
#
# Core dump will be written. Default location: Core dumps may be processed with "/opt/core.sh %p" (or dumping to /testoutput/test-support/jck_runtime_api_java_util/core.6599)
#
# If you would like to submit a bug report, please visit:
#   https://bugreport.java.com/bugreport/crash.jsp
#
Current CompileTask:
C2: 134735 11496    b        javasoft.sqe.tests.api.java.util.concurrent.atomic.AtomicIntegerFieldUpdater.GetAndUpdate::test (65 bytes)

Stack: [0x00007f3dd82fb000,0x00007f3dd83fc000],  sp=0x00007f3dd83f6fc0,  free space=1007k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xd43e36]  GraphKit::combine_exception_states(SafePointNode*, SafePointNode*) [clone .part.0]+0xc6
V  [libjvm.so+0xd4f22c]  GraphKit::replace_call(CallNode*, Node*, bool)+0x63c
V  [libjvm.so+0x825c0b]  CallGenerator::do_late_inline_helper()+0xbbb
V  [libjvm.so+0xa04b3d]  Compile::inline_incrementally_one()+0x33d
V  [libjvm.so+0xa05427]  Compile::process_late_inline_calls_no_inline(PhaseIterGVN&)+0x117
V  [libjvm.so+0xa06d70]  Compile::Optimize()+0x1860
V  [libjvm.so+0xa084b8]  Compile::Compile(ciEnv*, ciMethod*, int, bool, bool, bool, bool, bool, DirectiveSet*)+0x1588
V  [libjvm.so+0x81cd56]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x646
V  [libjvm.so+0xa18711]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0xd31
V  [libjvm.so+0xa19448]  CompileBroker::compiler_thread_loop()+0x598
V  [libjvm.so+0x1886a5c]  JavaThread::thread_main_inner()+0x27c
V  [libjvm.so+0x188d050]  Thread::call_run()+0x100
V  [libjvm.so+0x156b244]  thread_native_entry(Thread*)+0x104

Comments
I can still reproduce the same assert failure and filed JDK-8275638.
20-10-2021

Fix request (17u): The bug leads to an assert in C2 (regression in JDK 17). The fix is low risk (bail out) and has been tested in the JDK 18 for a while and with tier1-3 in JDK 17u. The patch applies cleanly.
28-09-2021

This fix is integrated in jdk-18+14-695.
03-09-2021

Changeset: 632a7e08 Author: Vladimir Ivanov <vlivanov@openjdk.org> Date: 2021-09-02 11:46:19 +0000 URL: https://git.openjdk.java.net/jdk/commit/632a7e0885596b70d34be319bd09d4df8e151d12
02-09-2021

Vladimir, please have a look.
31-08-2021

This is related to IncrementalInlineVirtual (JDK-8257211) and seems to be a regression from JDK-8271276.
31-08-2021

ILW = Assert during C2 compilation, intermittent but reliably reproducible with stress flags, -XX:-IncrementalInlineVirtual = HMM = P2
31-08-2021

I can reproduce the issue reliably by running tests with "-XX:+UnlockExperimentalVMOptions -XX:PerMethodSpecTrapLimit=0 -XX:PerMethodTrapLimit=0".
31-08-2021