JDK-8213898 : CDS dumping of springboot asserts in G1ArchiveAllocator::alloc_new_region
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 12
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2018-11-14
  • Updated: 2023-10-27
  • Resolved: 2018-11-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 11 JDK 12
11.0.22Fixed 12 b21Fixed
Related Reports
Relates :  
Description
java -XX:-UsePerfData -XX:CICompilerCount=2 -XX:TieredStopAtLevel=1 -Xmx128m -DautoQuit=true -XX:+UnlockDiagnosticVMOptions -XX:-UseAOT -Xshare:dump -XX:+IgnoreEmptyClassPaths -Xlog:class+path=info -XX:SharedArchiveFile=App.jsa -XX:SharedClassListFile=App.classlist -jar ./spring-greeting-1.13.jar
[....]
Allocating RW objects ... 
Allocating RO objects ... 
Relocating embedded pointers ... 
Relocating external roots ... 
Verifying external roots ... 
Dumping symbol table ...
Dumping objects to closed archive heap region ...
# To suppress the following error report, specify this argument
# after -XX: or in .hotspotrc:  SuppressErrorAt=/heapRegionManager.inline.hpp:43
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  Internal Error (/home/iklam/jdk/eva/open/src/hotspot/share/gc/g1/heapRegionManager.inline.hpp:43), pid=16438, tid=16457
#  assert(is_available(index)) failed: pre-condition

(gdb) where

#5  0x00007ffff5c91f7d in report_vm_error (file=file@entry=0x7ffff6b6a990 "open/src/hotspot/share/gc/g1/heapRegionManager.inline.hpp", line=line@entry=43, 
    error_msg=error_msg@entry=0x7ffff6b95a58 "assert(is_available(index)) failed", detail_fmt=detail_fmt@entry=0x7ffff6c9ae0b "pre-condition") at open/src/hotspot/share/utilities/debug.cpp:230
#6  0x00007ffff5e2cd07 in HeapRegionManager::at (this=0x7ffff0029420, index=126) at open/src/hotspot/share/gc/g1/heapRegionManager.inline.hpp:43
#7  0x00007ffff5e23936 in HeapRegionManager::allocate_free_regions_starting_at (num_regions=1, first=126, this=0x7ffff0029420) at open/src/hotspot/share/gc/g1/heapRegionManager.inline.hpp:77
#8  G1CollectedHeap::alloc_highest_free_region (this=0x7ffff0029310) at open/src/hotspot/share/gc/g1/g1CollectedHeap.cpp:4553
#9  0x00007ffff5df2f7d in G1ArchiveAllocator::alloc_new_region (this=this@entry=0x7fff884c2e50) at open/src/hotspot/share/gc/g1/g1Allocator.cpp:353
#10 0x00007ffff5df3958 in G1ArchiveAllocator::archive_mem_allocate (this=0x7fff884c2e50, word_size=word_size@entry=7) at open/src/hotspot/share/gc/g1/g1Allocator.cpp:385
#11 0x00007ffff5e179b2 in G1CollectedHeap::archive_mem_allocate (this=<optimized out>, word_size=word_size@entry=7) at open/src/hotspot/share/gc/g1/g1CollectedHeap.cpp:539
#12 0x00007ffff5f8fec1 in HeapShared::archive_heap_object (obj=..., __the_thread__=__the_thread__@entry=0x7ffff03eb930) at open/src/hotspot/share/memory/heapShared.cpp:134
#13 0x00007ffff683accd in StringTable::create_archived_string (s=..., __the_thread__=0x7ffff03eb930) at open/src/hotspot/share/classfile/stringTable.cpp:805
#14 0x00007ffff684102c in CopyToArchive::operator() (this=this@entry=0x7fffd6c307a0, val=val@entry=0x7ffff2f4ad08) at open/src/hotspot/share/classfile/stringTable.cpp:834
#15 0x00007ffff683c644 in ConcurrentHashTable<WeakHandle<(WeakHandleType)2>, StringTableConfig, (MemoryType)9>::visit_nodes<CopyToArchive> (visitor_f=..., bucket=<optimized out>)
    at open/src/hotspot/share/utilities/concurrentHashTable.inline.hpp:955
#16 ConcurrentHashTable<WeakHandle<(WeakHandleType)2>, StringTableConfig, (MemoryType)9>::do_scan_locked<CopyToArchive> (scan_f=..., thread=0x7ffff03eb930, this=0x7ffff01642a0)
    at open/src/hotspot/share/utilities/concurrentHashTable.inline.hpp:974
#17 ConcurrentHashTable<WeakHandle<(WeakHandleType)2>, StringTableConfig, (MemoryType)9>::do_scan<CopyToArchive> (scan_f=..., thread=0x7ffff03eb930, this=0x7ffff01642a0)
    at open/src/hotspot/share/utilities/concurrentHashTable.inline.hpp:1121
#18 StringTable::copy_shared_string_table (writer=writer@entry=0x7fffd6c30820) at open/src/hotspot/share/classfile/stringTable.cpp:850
#19 0x00007ffff683c8d1 in StringTable::write_to_archive () at open/src/hotspot/share/classfile/stringTable.cpp:863
#20 0x00007ffff5f937ec in HeapShared::copy_closed_archive_heap_objects (closed_archive=closed_archive@entry=0x7ffff29614e0) at open/src/hotspot/share/memory/heapShared.cpp:219
#21 0x00007ffff5f93b26 in HeapShared::archive_java_heap_objects (closed=0x7ffff29614e0, open=open@entry=0x7ffff2961540) at open/src/hotspot/share/memory/heapShared.cpp:200
#22 0x00007ffff651f7cb in VM_PopulateDumpSharedSpace::dump_java_heap_objects (this=this@entry=0x7ffff7fc7b90) at open/src/hotspot/share/memory/metaspaceShared.cpp:1769
#23 0x00007ffff652328b in VM_PopulateDumpSharedSpace::doit (this=<optimized out>) at open/src/hotspot/share/memory/metaspaceShared.cpp:1407
#24 0x00007ffff6a5bd96 in VM_Operation::evaluate (this=this@entry=0x7ffff7fc7b90) at open/src/hotspot/share/runtime/vm_operations.cpp:67
#25 0x00007ffff6a57b21 in VMThread::evaluate_operation (this=this@entry=0x7ffff03eb930, op=0x7ffff7fc7b90) at open/src/hotspot/share/runtime/vmThread.cpp:372
#26 0x00007ffff6a585de in VMThread::loop (this=this@entry=0x7ffff03eb930) at open/src/hotspot/share/runtime/vmThread.cpp:495
#27 0x00007ffff6a58d75 in VMThread::run (this=0x7ffff03eb930) at open/src/hotspot/share/runtime/vmThread.cpp:267
#28 0x00007ffff694f71d in Thread::call_run (this=0x7ffff03eb930) at open/src/hotspot/share/runtime/thread.cpp:378
#29 0x00007ffff66426e8 in thread_native_entry (thread=0x7ffff03eb930) at open/src/hotspot/os/linux/os_linux.cpp:701
#30 0x00007ffff77986ba in start_thread (arg=0x7fffd6c31700) at pthread_create.c:333
#31 0x00007ffff72ca41d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109

Comments
[jdk11u-fix-request] Approval Request from SUN Guoyun Fix Request jdk11u Applies cleanly. no risk. test tier1 passed.
24-10-2023

A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/2204 Date: 2023-10-21 06:08:25 +0000
21-10-2023

URL: http://hg.openjdk.java.net/jdk/jdk/rev/4d8a023c2a03 User: jiangli Date: 2018-11-16 18:36:59 +0000
16-11-2018

[~tschatzl]Thanks for the review! The bug only showed up when dumping the springboot classes.
15-11-2018

That looks good to me. Sorry for not catching that in the original change.
15-11-2018

[~tschatzl]Could you please take a look of the above proposed fix to see if that's proper? Thanks!
15-11-2018

Proposed fix: diff --git a/src/hotspot/share/gc/g1/heapRegionManager.cpp b/src/hotspot/share/gc/g1/heapRegionManager.cpp --- a/src/hotspot/share/gc/g1/heapRegionManager.cpp +++ b/src/hotspot/share/gc/g1/heapRegionManager.cpp @@ -320,7 +320,7 @@ uint curr = max_length() - 1; while (true) { HeapRegion *hr = _regions.get_by_index(curr); - if (hr == NULL) { + if (hr == NULL || !is_available(curr)) { uint res = expand_at(curr, 1, NULL); if (res == 1) { *expanded = true; If a region is not available, expand_at() will commit the region and make it available (also insert to the free list). webrev: http://cr.openjdk.java.net/~jiangli/8213898/webrev.00/
15-11-2018

The region (with index 126) is obtained from _regions maintained by HeapRegionManager. During HeapRegionManager::uncommit_regions, a region is cleared from _available_map (and other data also). It's not remove from _regions. That's why we are seeing a region that's not 'available' during HeapRegionManager::find_highest_free() call at later point.
14-11-2018

The region with index 126 has been uncommitted during G1CollectedHeap::resize_heap_if_necessary. This started to happen after the recent work for allowing heap shrinking / memory unmapping after reclaiming regions during Remark, JDK-6490394. The problem was hidden before because shrinking was only done after full GC.
14-11-2018