JDK-8340230 : Tests crash: assert(is_in_encoding_range || k->is_interface() || k->is_abstract()) failed: sanity
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 24
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-09-17
  • Updated: 2024-09-23
  • Resolved: 2024-09-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 23 JDK 24
23.0.2Fixed 24 b16Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
Test compiler/arraycopy/TestObjectArrayClone.java

CompileCommand: compileonly compiler/arraycopy/TestObjectArrayClone.testClone* bool compileonly = true
CompileCommand: compileonly jdk/internal/reflect/GeneratedMethodAccessor*.invoke bool compileonly = true
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/opt/mach5/mesos/work_dir/slaves/a4a7850a-7c35-410a-b879-d77fbb2f6087-S144935/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/1a4487ac-c1a9-48f2-a0e2-2fb14ee558dc/runs/2bb98958-12aa-4165-b8b3-ef1d44c4a59d/workspace/open/src/hotspot/share/ci/ciKlass.hpp:113), pid=1791476, tid=1791492
#  assert(is_in_encoding_range || k->is_interface() || k->is_abstract()) failed: sanity
#
# JRE version: Java(TM) SE Runtime Environment (24.0+16) (fastdebug build 24-ea+16-1711)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 24-ea+16-1711, mixed mode, compressed oops, g1 gc, linux-aarch64)
# Problematic frame:
# V  [libjvm.so+0x8b39c4]  Compile::final_graph_reshaping_main_switch(Node*, Final_Reshape_Counts&, unsigned int, Unique_Node_List&)+0x22b4


---------------  T H R E A D  ---------------

Current thread (0x0000ffffa42a0da0):  JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=1791492, stack(0x0000ffff88aa8000,0x0000ffff88ca6000) (2040K)]


Current CompileTask:
C2:5081   29             compiler.arraycopy.TestObjectArrayClone::testCloneShortObjectArray (47 bytes)

Stack: [0x0000ffff88aa8000,0x0000ffff88ca6000],  sp=0x0000ffff88ca07c0,  free space=2017k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x8b39c4]  Compile::final_graph_reshaping_main_switch(Node*, Final_Reshape_Counts&, unsigned int, Unique_Node_List&)+0x22b4  (ciKlass.hpp:113)
V  [libjvm.so+0x8b4140]  Compile::final_graph_reshaping_impl(Node*, Final_Reshape_Counts&, Unique_Node_List&) [clone .part.0]+0x160  (compile.cpp:3155)
V  [libjvm.so+0x8b49e8]  Compile::final_graph_reshaping_walk(Node_Stack&, Node*, Final_Reshape_Counts&, Unique_Node_List&)+0x148  (compile.cpp:3104)
V  [libjvm.so+0x8bfd08]  Compile::final_graph_reshaping()+0x4b8  (compile.cpp:4012)
V  [libjvm.so+0x8c1444]  Compile::Optimize()+0xb04  (compile.cpp:2486)
V  [libjvm.so+0x8c4150]  Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x14b0  (compile.cpp:852)
V  [libjvm.so+0x7187b0]  C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x17c  (c2compiler.cpp:142)
V  [libjvm.so+0x8cff94]  CompileBroker::invoke_compiler_on_method(CompileTask*)+0x864  (compileBroker.cpp:2303)
V  [libjvm.so+0x8d0b44]  CompileBroker::compiler_thread_loop()+0x514  (compileBroker.cpp:1961)
V  [libjvm.so+0xd2ed70]  JavaThread::thread_main_inner()+0xcc  (javaThread.cpp:758)
V  [libjvm.so+0x15a9500]  Thread::call_run()+0xac  (thread.cpp:225)
V  [libjvm.so+0x12fc9f4]  thread_native_entry(Thread*)+0x130  (os_linux.cpp:858)
C  [libc.so.6+0x806b8]  start_thread+0x2d8
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk17u-dev/pull/2910 Date: 2024-09-23 12:49:54 +0000
23-09-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk21u-dev/pull/1001 Date: 2024-09-23 12:48:10 +0000
23-09-2024

[jdk23u-fix-request] Approval Request from Martin The failing assertion is not in 23u, but using DecodeN without CompressedOops or DecodeNKlass without CompressedClassPointers is a potential risk and can cause errors on some platforms. The fix is trivial and the backport has been reviewed. SAP's nightly tests have passed and no regression has been observed.
20-09-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk23u/pull/104 Date: 2024-09-18 11:02:19 +0000
18-09-2024

Changeset: 3895b8fc Branch: master Author: Martin Doerr <mdoerr@openjdk.org> Date: 2024-09-18 08:26:33 +0000 URL: https://git.openjdk.org/jdk/commit/3895b8fc0b2c6d187080dba6fe08297adad4a480
18-09-2024

Thanks for verifying it! I'll run it through our nightly tests and probably integrate it tomorrow. I will also consider backports to at least some OpenJDK LTS releases.
17-09-2024

Testing is not all done yet but the relevant tests passed, so I's say this is good to go.
17-09-2024

My previous reproducer stops reproducing the problem with the suggested patch.
17-09-2024

Sure, I submitted testing and will report back once it passed.
17-09-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/21036 Date: 2024-09-17 10:45:09 +0000
17-09-2024

I couldn't reproduce it on my machine. Can you verify the PR, please? I think this fix is a candidate for backports regardless of JDK-8340012. It's not a good thing if we get DecodeNNodes etc. when UseCompressedOops is off or DecodeNKlassNodes etc. when UseCompressedClassPointers is off.
17-09-2024

Thanks Martin!
17-09-2024

The logic in compile.cpp doesn't handle cases correctly in which exactly one of UseCompressedOops and UseCompressedClassPointers is enabled. JDK-8340012 only uncovered this problem. The transformation should only be done for the part which is enabled, not for the other one. I'll fix it.
17-09-2024

ILW = Assert during C2 compilation (invalid assumption, recent regression), reproducible with -XX:-UseCompressedKlassPointers, no workaround but enable UseCompressedKlassPointers or disable compilation of affected method = HMM = P2
17-09-2024

Martin, could you please have a look asap? Thanks.
17-09-2024

It's a regression from JDK-8340012.
17-09-2024

Also test serviceability/dcmd/vm/ClassLoaderStatsTest.java#id1
17-09-2024

We crash here: We crash in this code: if ((UseCompressedOops || UseCompressedClassPointers) && addp->Opcode() == Op_ConP && addp == n->in(AddPNode::Base) && n->in(AddPNode::Offset)->is_Con()) { // If the transformation of ConP to ConN+DecodeN is beneficial depends // on the platform and on the compressed oops mode. // Use addressing with narrow klass to load with offset on x86. // Some platforms can use the constant pool to load ConP. // Do this transformation here since IGVN will convert ConN back to ConP. const Type* t = addp->bottom_type(); bool is_oop = t->isa_oopptr() != nullptr; bool is_klass = t->isa_klassptr() != nullptr; if ((is_oop && Matcher::const_oop_prefer_decode() ) || (is_klass && Matcher::const_klass_prefer_decode() && t->isa_klassptr()->exact_klass()->is_in_encoding_range())) { on the last line because the code seems to assume that we are running UseCompressedKlassPointers.
17-09-2024

I ca reproduce this even with JDK-8340184. Note that the test fails when we turn off UseCompressedKlassPointers.
17-09-2024

Also test: compiler/unsafe/OpaqueAccesses.java # # A fatal error has been detected by the Java Runtime Environment: # # Internal Error (/opt/mach5/mesos/work_dir/slaves/a4a7850a-7c35-410a-b879-d77fbb2f6087-S144935/frameworks/1735e8a2-a1db-478c-8104-60c8b0af87dd-0196/executors/1a4487ac-c1a9-48f2-a0e2-2fb14ee558dc/runs/2bb98958-12aa-4165-b8b3-ef1d44c4a59d/workspace/open/src/hotspot/share/ci/ciKlass.hpp:113), pid=1708675, tid=1708691 # assert(is_in_encoding_range || k->is_interface() || k->is_abstract()) failed: sanity # # JRE version: Java(TM) SE Runtime Environment (24.0+16) (fastdebug build 24-ea+16-1711) # Java VM: Java HotSpot(TM) 64-Bit Server VM (fastdebug 24-ea+16-1711, mixed mode, compressed oops, g1 gc, linux-aarch64) # Problematic frame: # V [libjvm.so+0x8b39c4] Compile::final_graph_reshaping_main_switch(Node*, Final_Reshape_Counts&, unsigned int, Unique_Node_List&)+0x22b4 --------------- T H R E A D --------------- Current thread (0x0000ffffa83fade0): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=1708691, stack(0x0000ffff7b208000,0x0000ffff7b406000) (2040K)] Current CompileTask: C2:396 70 b java.util.HashMap::putVal (300 bytes) Stack: [0x0000ffff7b208000,0x0000ffff7b406000], sp=0x0000ffff7b400930, free space=2018k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) V [libjvm.so+0x8b39c4] Compile::final_graph_reshaping_main_switch(Node*, Final_Reshape_Counts&, unsigned int, Unique_Node_List&)+0x22b4 (ciKlass.hpp:113) V [libjvm.so+0x8b4140] Compile::final_graph_reshaping_impl(Node*, Final_Reshape_Counts&, Unique_Node_List&) [clone .part.0]+0x160 (compile.cpp:3155) V [libjvm.so+0x8b49e8] Compile::final_graph_reshaping_walk(Node_Stack&, Node*, Final_Reshape_Counts&, Unique_Node_List&)+0x148 (compile.cpp:3104) V [libjvm.so+0x8bfd08] Compile::final_graph_reshaping()+0x4b8 (compile.cpp:4012) V [libjvm.so+0x8c1444] Compile::Optimize()+0xb04 (compile.cpp:2486) V [libjvm.so+0x8c4150] Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x14b0 (compile.cpp:852) V [libjvm.so+0x7187b0] C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x17c (c2compiler.cpp:142) V [libjvm.so+0x8cff94] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x864 (compileBroker.cpp:2303) V [libjvm.so+0x8d0b44] CompileBroker::compiler_thread_loop()+0x514 (compileBroker.cpp:1961) V [libjvm.so+0xd2ed70] JavaThread::thread_main_inner()+0xcc (javaThread.cpp:758) V [libjvm.so+0x15a9500] Thread::call_run()+0xac (thread.cpp:225) V [libjvm.so+0x12fc9f4] thread_native_entry(Thread*)+0x130 (os_linux.cpp:858) C [libpthread.so.0+0x7950] start_thread+0x190
17-09-2024

May also be related to JDK-8340012
17-09-2024

Unclear if this could be the issue described by JDK-8340184
17-09-2024