JDK-8371874 : AOTLinkedClassBulkLoader::preload_classes() should not allocate heap objects
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 26
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2025-11-14
  • Updated: 2025-11-24
  • Resolved: 2025-11-14
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 26
26 b25Fixed
Related Reports
Blocks :  
Description
In JDK-8371643 review, the following crash was found. The reason is java_lang_Class::restore_archived_mirror() can allocate an int array. 

https://github.com/openjdk/jdk/blob/7733632f90a17ec848c4c9259c1aa58fded8c15a/src/hotspot/share/classfile/javaClasses.cpp#L1246-L1247

However, during AOTLinkedClassBulkLoader::preload_classes(), CollectedHeap::set_filler_object_klass() has not yet been called, so it's not safe to allocate heap objects yet.

=======================

make run-test TEST=runtime/cds/appcds/aotClassLinking/LambdaInExcludedClass.java JTREG="VM_OPTIONS=-XX:+UseCompactObjectHeaders":

SIGSEGV (0xb) at pc=0x00007f2f95a61e7a, pid=18554, tid=18557
V  [libjvm.so+0x15bfe7a]  MemAllocator::finish(HeapWordImpl**) const+0xca  (klass.inline.hpp:72)
V  [libjvm.so+0x15c029f]  ObjAllocator::initialize(HeapWordImpl**) const+0x2f  (memAllocator.cpp:391)
V  [libjvm.so+0xb0630b]  CollectedHeap::fill_with_object(HeapWordImpl**, unsigned long, bool)+0x27b  (collectedHeap.cpp:491)
V  [libjvm.so+0x1c7a0bb]  ThreadLocalAllocBuffer::retire(ThreadLocalAllocStats*)+0x11b  (threadLocalAllocBuffer.cpp:118)
V  [libjvm.so+0x15c0b14]  MemAllocator::mem_allocate_inside_tlab_slow(MemAllocator::Allocation&) const+0x84  (memAllocator.cpp:286)
V  [libjvm.so+0x15c13ab]  MemAllocator::mem_allocate(MemAllocator::Allocation&) const+0xbb  (memAllocator.cpp:340)
V  [libjvm.so+0x15c14f9]  MemAllocator::allocate() const+0xa9  (memAllocator.cpp:353)
V  [libjvm.so+0x1cc052e]  TypeArrayKlass::allocate_common(int, bool, JavaThread*)+0x13e  (collectedHeap.inline.hpp:41)
V  [libjvm.so+0x16fbc98]  oopFactory::new_typeArray(BasicType, int, JavaThread*)+0x38  (typeArrayKlass.hpp:51)
V  [libjvm.so+0x106b0f3]  java_lang_Class::restore_archived_mirror(Klass*, Handle, Handle, Handle, JavaThread*)+0x413  (javaClasses.cpp:1246)
V  [libjvm.so+0x14100bc]  Klass::restore_unshareable_info(ClassLoaderData*, Handle, JavaThread*)+0x66c  (klass.cpp:903)
V  [libjvm.so+0xfe2cb1]  InstanceKlass::restore_unshareable_info(ClassLoaderData*, Handle, PackageEntry*, JavaThread*)+0x81  (instanceKlass.cpp:2823)
V  [libjvm.so+0x1c0f5ad]  SystemDictionary::preload_class(Handle, InstanceKlass*, JavaThread*)+0x1ed  (systemDictionary.cpp:1198)
V  [libjvm.so+0x676e83]  AOTLinkedClassBulkLoader::preload_classes_in_table(Array<InstanceKlass*>*, char const*, Handle, JavaThread*)+0x1a3  (aotLinkedClassBulkLoader.cpp:103)
V  [libjvm.so+0x679af5]  AOTLinkedClassBulkLoader::preload_classes_impl(JavaThread*)+0x165  (aotLinkedClassBulkLoader.cpp:76)
V  [libjvm.so+0x67c371]  AOTLinkedClassBulkLoader::preload_classes(JavaThread*)+0x11  (aotLinkedClassBulkLoader.cpp:61)
V  [libjvm.so+0x1d5bf30]  vmClasses::resolve_all(JavaThread*)+0x3e0  (vmClasses.cpp:126)
V  [libjvm.so+0x1c0f28c]  SystemDictionary::initialize(JavaThread*)+0x10c  (systemDictionary.cpp:1623)
V  [libjvm.so+0x1cc74ca]  Universe::genesis(JavaThread*)+0xfa  (universe.cpp:451)
V  [libjvm.so+0x1ccbbf5]  universe2_init()+0x35  (universe.cpp:1119)
V  [libjvm.so+0xfd5709]  init_globals2()+0x9  (init.cpp:173)
V  [libjvm.so+0x1c926b1]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x3a1  (threads.cpp:622)
V  [libjvm.so+0x118b634]  JNI_CreateJavaVM+0x54  (jni.cpp:3591)
C  [libjli.so+0x3d7f]  JavaMain+0x8f  (java.c:1506)
C  [libjli.so+0x7ad9]  ThreadJavaMain+0x9  (java_md.c:646)
Comments
Changeset: 58b601ac Branch: master Author: Ioi Lam <iklam@openjdk.org> Date: 2025-11-14 18:41:50 +0000 URL: https://git.openjdk.org/jdk/commit/58b601ac4250a455e3f25f8505ead8c130eba642
14-11-2025

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/28315 Date: 2025-11-14 04:43:51 +0000
14-11-2025