8209971: TestOptionsWithRanges.java crashes in CDS mode with G1UpdateBufferSize=1

Fixup archive heap regions before restoring any archived java object at runtime.

Reviewed-by: iklam, ccheung
This commit is contained in:
Jiangli Zhou 2018-09-07 15:18:14 -04:00
parent 8b1bdf579c
commit bd77f790c3
5 changed files with 37 additions and 5 deletions

View file

@ -2028,6 +2028,22 @@ void SystemDictionary::resolve_preloaded_classes(TRAPS) {
#if INCLUDE_CDS
if (UseSharedSpaces) {
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Object_klass), scan, CHECK);
// It's unsafe to access the archived heap regions before they
// are fixed up, so we must do the fixup as early as possible
// before the archived java objects are accessed by functions
// such as java_lang_Class::restore_archived_mirror and
// ConstantPool::restore_unshareable_info (restores the archived
// resolved_references array object).
//
// MetaspaceShared::fixup_mapped_heap_regions() fills the empty
// spaces in the archived heap regions and may use
// SystemDictionary::Object_klass(), so we can do this only after
// Object_klass is resolved. See the above resolve_wk_klasses_through()
// call. No mirror objects are accessed/restored in the above call.
// Mirrors are restored after java.lang.Class is loaded.
MetaspaceShared::fixup_mapped_heap_regions();
// Initialize the constant pool for the Object_class
Object_klass()->constants()->restore_unshareable_info(CHECK);
resolve_wk_klasses_through(WK_KLASS_ENUM_NAME(Class_klass), scan, CHECK);