JDK-8339694 : ciTypeFlow does not correctly handle unresolved constant dynamic of array type
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 19,21,23,24
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-09-06
  • Updated: 2024-10-24
  • Resolved: 2024-10-18
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
24 b21Fixed
Related Reports
Relates :  
Description
The test 

runtime/condy/escapeAnalysis/TestEscapeCondy.java

fails with -Xcomp.

Please, note that test just updated to accept VM flags and problemlisted. See PR:
https://github.com/openjdk/jdk/pull/20894

To reproduce:
1) Change test
diff --git a/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java b/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java
--- a/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java	(revision 38441b3f2d0e735089c29a9a9ce441b2d7c75db1)
+++ b/test/hotspot/jtreg/runtime/condy/escapeAnalysis/TestEscapeCondy.java	(date 1726038766040)
@@ -26,7 +26,6 @@
  * @bug 8216970
  * @summary Ensure escape analysis can handle an ldc of a dynamic
  *          constant whose return type is an array of boolean.
- * @requires vm.flagless
  * @modules java.base/jdk.internal.misc
  * @library /test/lib
  * @compile TestEscapeThroughInvokeWithCondy$A.jasm
@@ -43,7 +42,7 @@
     public static void main(String args[]) throws Throwable {
         // 1. Test escape analysis of a method that contains
         //    a ldc instruction of a condy whose return type is an array of boolean
-        ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
+        ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
              "-XX:CompileCommand=dontinline,runtime.condy.TestEscapeThroughInvokeWithCondy::create",
              "runtime.condy.TestEscapeThroughInvokeWithCondy");
         OutputAnalyzer oa = new OutputAnalyzer(pb.start());


2) Run test with additional flags -Xcomp -XX:CompileOnly=*TestEscapeThroughInvokeWithCondy::*

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/a4a7850a-7c35-410a-b879-d77fbb2f6087-S144280/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/08836cc8-8e7f-4a71-8d0a-d202f86f4453/runs/e724b40e-6086-4fa3-b912-d25c41311728/workspace/open/src/hotspot/share/ci/ciTypeFlow.hpp:346), pid=88876, tid=88891
#  assert(array->is_type_array_klass()) failed: must be prim array type
#
# JRE version: Java(TM) SE Runtime Environment (24.0+15) (fastdebug build 24-ea+15-1632)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 24-ea+15-1632, compiled mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0x93c6d4]  ciTypeFlow::StateVector::pop_typeArray() [clone .isra.0]+0xc4
..........
Command Line: -Xcomp -XX:CompileOnly=*TestEscapeThroughInvokeWithCondy::* -XX:CompileCommand=dontinline,runtime.condy.TestEscapeThroughInvokeWithCondy::create runtime.condy.TestEscapeThroughInvokeWithCondy
..........
Current CompileTask:
C2:57    6    b  4       runtime.condy.TestEscapeThroughInvokeWithCondy::create (27 bytes)

Stack: [0x0000791487800000,0x0000791487900000],  sp=0x00007914878fc690,  free space=1009k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x93c6d4]  ciTypeFlow::StateVector::pop_typeArray() [clone .isra.0]+0xc4  (ciTypeFlow.hpp:346)
V  [libjvm.so+0x9419a8]  ciTypeFlow::StateVector::apply_one_bytecode(ciBytecodeStream*)+0x238  (ciTypeFlow.cpp:971)
V  [libjvm.so+0x946130]  ciTypeFlow::flow_block(ciTypeFlow::Block*, ciTypeFlow::StateVector*, ciTypeFlow::JsrSet*)+0x1e0  (ciTypeFlow.cpp:2428)
V  [libjvm.so+0x947839]  ciTypeFlow::df_flow_types(ciTypeFlow::Block*, bool, ciTypeFlow::StateVector*, ciTypeFlow::JsrSet*)+0x449  (ciTypeFlow.cpp:2843)
V  [libjvm.so+0x947ce3]  ciTypeFlow::flow_types()+0x263  (ciTypeFlow.cpp:2893)
V  [libjvm.so+0x949246]  ciTypeFlow::do_flow()+0x26  (ciTypeFlow.cpp:3054)
V  [libjvm.so+0x8f0914]  ciMethod::get_flow_analysis()+0x64  (ciMethod.cpp:330)
V  [libjvm.so+0x70843b]  InlineTree::check_can_parse(ciMethod*)+0x5b  (bytecodeInfo.cpp:532)
V  [libjvm.so+0x8555d8]  CallGenerator::for_inline(ciMethod*, float)+0x18  (callGenerator.cpp:293)
V  [libjvm.so+0xa006eb]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x147b  (compile.cpp:776)
V  [libjvm.so+0x850255]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5  (c2compiler.cpp:142)
V  [libjvm.so+0xa0ca78]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928  (compileBroker.cpp:2303)
V  [libjvm.so+0xa0d708]  CompileBroker::compiler_thread_loop()+0x478  (compileBroker.cpp:1961)
V  [libjvm.so+0xeb40fc]  JavaThread::thread_main_inner()+0xcc  (javaThread.cpp:758)
V  [libjvm.so+0x17e13c6]  Thread::call_run()+0xb6  (thread.cpp:225)
V  [libjvm.so+0x14ca587]  thread_native_entry(Thread*)+0x127  (os_linux.cpp:858)
Comments
Changeset: c51a086c Branch: master Author: Tobias Hartmann <thartmann@openjdk.org> Date: 2024-10-18 06:46:23 +0000 URL: https://git.openjdk.org/jdk/commit/c51a086ce32dd4e97aa83dfba3bcf9b0636193cc
18-10-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/21470 Date: 2024-10-11 13:44:46 +0000
14-10-2024

The problem is an unresolved constant dynamic of array type. After JDK-8280473, the ci will represent it as unloaded ciConstant of a java/lang/Object ciInstanceKlass: <ciInstanceKlass name=java/lang/Object loaded=true loader=0x0000000000000000 initialized=true finalized=false subklass=true size=16 flags=public ident=1252 address=0x00006532f3f24318> https://github.com/openjdk/jdk/blob/6133866150cf6131ab578f1537f84c239703fa67/src/hotspot/share/ci/ciEnv.cpp#L723 We assert on access (bastore) because the type is not a primitive array type: https://github.com/openjdk/jdk/blob/6133866150cf6131ab578f1537f84c239703fa67/src/hotspot/share/ci/ciTypeFlow.cpp#L971 The same problem exists with object array types: # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/workspace/open/src/hotspot/share/ci/ciTypeFlow.hpp:340), pid=76312, tid=76328 # assert(array->is_obj_array_klass()) failed: must be object array type # # JRE version: Java(TM) SE Runtime Environment (24.0+18) (fastdebug build 24-ea+18-2073) # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 24-ea+18-2073, compiled mode, sharing, compressed oops, compressed class ptrs, g1 gc, linux-amd64) # Problematic frame: # V [libjvm.so+0x976df9] ciTypeFlow::StateVector::pop_objArray()+0xd9 Current CompileTask: C2:104 26 b TestUnresolvedConstantDynamicHelper::testStringArray (7 bytes) Stack: [0x0000788f18000000,0x0000788f18100000], sp=0x0000788f180fc6f0, free space=1009k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x976df9] ciTypeFlow::StateVector::pop_objArray()+0xd9 (ciTypeFlow.hpp:340) V [libjvm.so+0x96edef] ciTypeFlow::StateVector::apply_one_bytecode(ciBytecodeStream*)+0x83f V [libjvm.so+0x972f70] ciTypeFlow::flow_block(ciTypeFlow::Block*, ciTypeFlow::StateVector*, ciTypeFlow::JsrSet*)+0x1e0 V [libjvm.so+0x974679] ciTypeFlow::df_flow_types(ciTypeFlow::Block*, bool, ciTypeFlow::StateVector*, ciTypeFlow::JsrSet*)+0x449 V [libjvm.so+0x974b23] ciTypeFlow::flow_types()+0x263 V [libjvm.so+0x976086] ciTypeFlow::do_flow()+0x26 V [libjvm.so+0x91b8d4] ciMethod::get_flow_analysis()+0x64 V [libjvm.so+0x7303fb] InlineTree::check_can_parse(ciMethod*)+0x5b V [libjvm.so+0x87df48] CallGenerator::for_inline(ciMethod*, float)+0x18 V [libjvm.so+0xa2f94b] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x14fb V [libjvm.so+0x878bc5] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x1d5 V [libjvm.so+0xa3bcd8] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x928 V [libjvm.so+0xa3c968] CompileBroker::compiler_thread_loop()+0x478 V [libjvm.so+0xeedc7c] JavaThread::thread_main_inner()+0xcc V [libjvm.so+0x1813a86] Thread::call_run()+0xb6 V [libjvm.so+0x14f8ee7] thread_native_entry(Thread*)+0x127
11-10-2024

ILW = Crash in CI type flow, only single test, disable compilation = HLM = P3
11-09-2024