JDK-8340012 : [C2] assert(KlassEncodingMetaspaceMax > pd) failed: change encoding max if new encoding after 8338526
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 24
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-09-12
  • Updated: 2024-09-23
  • Resolved: 2024-09-16
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 b16Fixed
Related Reports
Relates :  
Relates :  
Description
The test "applications/ctw/modules/java_xml.java" runs into this assertion on AIX when compiling "com.sun.org.apache.xalan.internal.xsltc.dom.DOMWSFilter::<init>" with C2. The Klass which can't be encoded is 0x0a00010091130af8
com.sun.org.apache.xalan.internal.xsltc.runtime.AbstractTranslet {0x0a00010091130af8}
 - instance size:     18
 - klass size:        118
 - access:            public synchronized abstract 
 - flags:             has_nonstatic_fields has_localvariable_table has_miranda_methods has_final_method 
 - state:             loaded
 - name:              &apos;com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet&apos;
 - super:             &apos;java/lang/Object&apos;
 - sub:               
 - arrays:            null
 - methods:           Array&lt;T&gt;(0x0a0001009112d130)
 - method ordering:   Array&lt;T&gt;(0x0a00010090000018)
 - local interfaces:  Array&lt;T&gt;(0x0a0001009112d120)
 - trans. interfaces: Array&lt;T&gt;(0x0a0001009112d120)
 - secondary supers: Array&lt;T&gt;(0x0a0001009112d120)
 - hash_slot:         45
 - bitmap:            0x0010000000000000
 - constants:         constant pool [727]/operands[35] {0x0a0001009112b8a8} for &apos;com/sun/org/apache/xalan/internal/xsltc/runtime/AbstractTranslet&apos;
 - class loader data:  loader data: 0x0000000114020150 of &apos;bootstrap&apos;
 - source file:       &apos;AbstractTranslet.java&apos;
 - inner classes:     Array&lt;T&gt;(0x0a000100911309b0)
 - nest members:     Array&lt;T&gt;(0x0a00010090000020)
 - permitted subclasses:     Array&lt;T&gt;(0x0a00010090000020)

C2 tries to encode it although it is abstract. The issue has only been observed on AIX so far.

Stack snippet:
0x00000001157ba0f0 - 0x090000001bb87ed0 libjvm.so::CompressedKlassPointers::encode_not_null(Klass*, unsigned char*, int)+0x128  (C++ uses_alloca saves_lr stores_bc gpr_saved:1 fixedparms:3 parmsonstk:1)
0x00000001157ba170 - 0x090000001c4d1fe4 libjvm.so::loadConNKlass_ExNode::postalloc_expand(GrowableArray<Node*>*, PhaseRegAlloc*)+0x23c  (C++ uses_alloca saves_lr stores_bc gpr_saved:10 fixedparms:3 parmsonstk:1)
0x00000001157ba230 - 0x090000001c6e7ec0 libjvm.so::PhaseCFG::postalloc_expand(PhaseRegAlloc*)+0x5bc  (C++ uses_alloca saves_cr saves_lr stores_bc gpr_saved:18 fixedparms:2 parmsonstk:1)
0x00000001157ba450 - 0x090000001c87eb50 libjvm.so::Compile::Code_Gen()+0x394  (C++ uses_alloca saves_lr stores_bc gpr_saved:6 fixedparms:1 parmsonstk:1)

"loadConNKlass_ExNode" is trying to load a ConNKlass into a RegN.

The transformation here is no longer valid with Klass pointers which can't be encoded: https://github.com/openjdk/jdk/blob/ab9b72c50a5f324e53b8c6535f401cc185b98c75/src/hotspot/share/opto/compile.cpp#L3317

I think that all platforms are affected on which Matcher::const_klass_prefer_decode() can become true. These are aarch64, ppc64, riscv, s390. However, the problem only arrises when C2 encounters a Klass outside the encodable range which depends on the location of the metaspace.


Comments
Changeset: 6be15c3d Branch: master Author: Martin Doerr <mdoerr@openjdk.org> Date: 2024-09-16 08:15:48 +0000 URL: https://git.openjdk.org/jdk/commit/6be15c3d0bf0bb3625f2ecd43d7aa10e81f6edd8
16-09-2024

ILW = Assert during C2 compilation (regression), reproducible with CTW on AIX, -XX:-UseCompressedClassPointers = HLM = P3
16-09-2024

Okay I'm sorry I didn't get this error. I guess the tests that I ran didn't run CTW.
12-09-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/20971 Date: 2024-09-12 17:16:08 +0000
12-09-2024

The issue is also visible on AIX in test applications/ctw/modules/java_base_2.java # Internal Error (/priv/jenkins/client-home/workspace/openjdk-jdk-dev-aix_ppc64-dbg/jdk/src/hotspot/share/oops/compressedKlass.inline.hpp:54), pid=14483960, tid=8996 # assert(KlassEncodingMetaspaceMax > pd) failed: change encoding max if new encoding Current CompileTask: C2:7018 1088 b 4 javax.crypto.MacSpi::clone (20 bytes) 0x000000011aaca050 - 0x090000001bad5418 libjvm.so::report_vm_error(char const*, int, char const*, char const*, ...)+0x8c (C++ uses_alloca saves_lr stores_bc gpr_saved:5 fixedparms:4 parmsonstk:1) 0x000000011aaca0f0 - 0x090000001bb87ed0 libjvm.so::CompressedKlassPointers::encode_not_null(Klass*, unsigned char*, int)+0x128 (C++ uses_alloca saves_lr stores_bc gpr_saved:1 fixedparms:3 parmsonstk:1) 0x000000011aaca170 - 0x090000001c4d1fe4 libjvm.so::loadConNKlass_ExNode::postalloc_expand(GrowableArray<Node*>*, PhaseRegAlloc*)+0x23c (C++ uses_alloca saves_lr stores_bc gpr_saved:10 fixedparms:3 parmsonstk:1) 0x000000011aaca230 - 0x090000001c6e7ec0 libjvm.so::PhaseCFG::postalloc_expand(PhaseRegAlloc*)+0x5bc (C++ uses_alloca saves_cr saves_lr stores_bc gpr_saved:18 fixedparms:2 parmsonstk:1) 0x000000011aaca450 - 0x090000001c87eb50 libjvm.so::Compile::Code_Gen()+0x394 (C++ uses_alloca saves_lr stores_bc gpr_saved:6 fixedparms:1 parmsonstk:1) 0x000000011aacb0b0 - 0x090000001c8fcbdc libjvm.so::Compile::Compile(ciEnv*, ciMethod*, int, Options, DirectiveSet*)+0x16b4 (C++ fp_present uses_alloca saves_cr saves_lr stores_bc gpr_saved:18 fixedparms:6 parmsonstk:1) 0x000000011aacbd30 - 0x090000001cb23d58 libjvm.so::C2Compiler::compile_method(ciEnv*, ciMethod*, int, bool, DirectiveSet*)+0x25c (C++ uses_alloca saves_cr saves_lr stores_bc gpr_saved:18 fixedparms:6 parmsonstk:1) 0x000000011aacca70 - 0x090000001be3b450 libjvm.so::CompileBroker::invoke_compiler_on_method(CompileTask*)+0xcf4 (C++ fp_present uses_alloca saves_cr saves_lr stores_bc gpr_saved:18 fixedparms:1 parmsonstk:1) 0x000000011aacd200 - 0x090000001be0fdf0 libjvm.so::CompileBroker::compiler_thread_loop()+0x4c0 (C++ fp_present uses_alloca saves_cr saves_lr stores_bc gpr_saved:18 parmsonstk:1) 0x000000011aacd450 - 0x090000001be0f8b0 libjvm.so::CompilerThread::thread_entry(JavaThread*, JavaThread*)+0x58 (C++ uses_alloca saves_lr stores_bc gpr_saved:1 fixedparms:2 parmsonstk:1) 0x000000011aacd4d0 - 0x090000001bd4c438 libjvm.so::JavaThread::thread_main_inner()+0x1f8 (C++ uses_alloca saves_lr stores_bc gpr_saved:4 fixedparms:1 parmsonstk:1) 0x000000011aacd5a0 - 0x090000001bd4a510 libjvm.so::JavaThread::run()+0x214 (C++ uses_alloca saves_lr stores_bc gpr_saved:5 fixedparms:1 parmsonstk:1) 0x000000011aacd640 - 0x090000001bbf9588 libjvm.so::Thread::call_run()+0x128 (C++ uses_alloca saves_lr stores_bc gpr_saved:3 fixedparms:1 parmsonstk:1) 0x000000011aacd6d0 - 0x090000001bbf8ae8 libjvm.so::thread_native_entry(Thread*)+0x214 (C++ uses_alloca saves_lr stores_bc gpr_saved:10 fixedparms:1 parmsonstk:1) 0x000000011aacd7a0 - 0x090000000056204c libpthreads.a::_pthread_body+0xec (C saves_lr stores_bc gpr_saved:1 fixedparms:1 )
12-09-2024