mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8185103: TestThreadDumpMonitorContention.java crashed due to SIGSEGV in G1SATBCardTableModRefBS::write_ref_field_pre_work
Ensure that a Klass's mirror is set before putting the Klass on the fixup_module_field_list Reviewed-by: coleenp, dholmes, gtriantafill
This commit is contained in:
parent
1005679aac
commit
2787fd2cd7
3 changed files with 23 additions and 13 deletions
|
@ -787,12 +787,9 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo
|
||||||
MutexLocker m1(Module_lock, THREAD);
|
MutexLocker m1(Module_lock, THREAD);
|
||||||
// Keep list of classes needing java.base module fixup
|
// Keep list of classes needing java.base module fixup
|
||||||
if (!ModuleEntryTable::javabase_defined()) {
|
if (!ModuleEntryTable::javabase_defined()) {
|
||||||
if (fixup_module_field_list() == NULL) {
|
assert(k->java_mirror() != NULL, "Class's mirror is null");
|
||||||
GrowableArray<Klass*>* list =
|
|
||||||
new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
|
|
||||||
set_fixup_module_field_list(list);
|
|
||||||
}
|
|
||||||
k->class_loader_data()->inc_keep_alive();
|
k->class_loader_data()->inc_keep_alive();
|
||||||
|
assert(fixup_module_field_list() != NULL, "fixup_module_field_list not initialized");
|
||||||
fixup_module_field_list()->push(k);
|
fixup_module_field_list()->push(k);
|
||||||
} else {
|
} else {
|
||||||
javabase_was_defined = true;
|
javabase_was_defined = true;
|
||||||
|
@ -816,10 +813,22 @@ void java_lang_Class::set_mirror_module_field(Klass* k, Handle mirror, Handle mo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Statically allocate fixup lists because they always get created.
|
||||||
|
void java_lang_Class::allocate_fixup_lists() {
|
||||||
|
GrowableArray<Klass*>* mirror_list =
|
||||||
|
new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true);
|
||||||
|
set_fixup_mirror_list(mirror_list);
|
||||||
|
|
||||||
|
GrowableArray<Klass*>* module_list =
|
||||||
|
new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
|
||||||
|
set_fixup_module_field_list(module_list);
|
||||||
|
}
|
||||||
|
|
||||||
void java_lang_Class::create_mirror(Klass* k, Handle class_loader,
|
void java_lang_Class::create_mirror(Klass* k, Handle class_loader,
|
||||||
Handle module, Handle protection_domain, TRAPS) {
|
Handle module, Handle protection_domain, TRAPS) {
|
||||||
assert(k != NULL, "Use create_basic_type_mirror for primitive types");
|
assert(k != NULL, "Use create_basic_type_mirror for primitive types");
|
||||||
assert(k->java_mirror() == NULL, "should only assign mirror once");
|
assert(k->java_mirror() == NULL, "should only assign mirror once");
|
||||||
|
|
||||||
// Use this moment of initialization to cache modifier_flags also,
|
// Use this moment of initialization to cache modifier_flags also,
|
||||||
// to support Class.getModifiers(). Instance classes recalculate
|
// to support Class.getModifiers(). Instance classes recalculate
|
||||||
// the cached flags after the class file is parsed, but before the
|
// the cached flags after the class file is parsed, but before the
|
||||||
|
@ -878,23 +887,21 @@ void java_lang_Class::create_mirror(Klass* k, Handle class_loader,
|
||||||
assert(class_loader() == k->class_loader(), "should be same");
|
assert(class_loader() == k->class_loader(), "should be same");
|
||||||
set_class_loader(mirror(), class_loader());
|
set_class_loader(mirror(), class_loader());
|
||||||
|
|
||||||
// set the module field in the java_lang_Class instance
|
|
||||||
set_mirror_module_field(k, mirror, module, THREAD);
|
|
||||||
|
|
||||||
// Setup indirection from klass->mirror
|
// Setup indirection from klass->mirror
|
||||||
// after any exceptions can happen during allocations.
|
// after any exceptions can happen during allocations.
|
||||||
k->set_java_mirror(mirror());
|
k->set_java_mirror(mirror());
|
||||||
|
|
||||||
|
// Set the module field in the java_lang_Class instance. This must be done
|
||||||
|
// after the mirror is set.
|
||||||
|
set_mirror_module_field(k, mirror, module, THREAD);
|
||||||
|
|
||||||
if (comp_mirror() != NULL) {
|
if (comp_mirror() != NULL) {
|
||||||
// Set after k->java_mirror() is published, because compiled code running
|
// Set after k->java_mirror() is published, because compiled code running
|
||||||
// concurrently doesn't expect a k to have a null java_mirror.
|
// concurrently doesn't expect a k to have a null java_mirror.
|
||||||
release_set_array_klass(comp_mirror(), k);
|
release_set_array_klass(comp_mirror(), k);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (fixup_mirror_list() == NULL) {
|
assert(fixup_mirror_list() != NULL, "fixup_mirror_list not initialized");
|
||||||
GrowableArray<Klass*>* list =
|
|
||||||
new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(40, true);
|
|
||||||
set_fixup_mirror_list(list);
|
|
||||||
}
|
|
||||||
fixup_mirror_list()->push(k);
|
fixup_mirror_list()->push(k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,7 @@ class java_lang_Class : AllStatic {
|
||||||
static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain, TRAPS);
|
static void initialize_mirror_fields(Klass* k, Handle mirror, Handle protection_domain, TRAPS);
|
||||||
static void set_mirror_module_field(Klass* K, Handle mirror, Handle module, TRAPS);
|
static void set_mirror_module_field(Klass* K, Handle mirror, Handle module, TRAPS);
|
||||||
public:
|
public:
|
||||||
|
static void allocate_fixup_lists();
|
||||||
static void compute_offsets();
|
static void compute_offsets();
|
||||||
|
|
||||||
// Instance creation
|
// Instance creation
|
||||||
|
|
|
@ -320,6 +320,8 @@ void Universe::genesis(TRAPS) {
|
||||||
|
|
||||||
{ MutexLocker mc(Compile_lock);
|
{ MutexLocker mc(Compile_lock);
|
||||||
|
|
||||||
|
java_lang_Class::allocate_fixup_lists();
|
||||||
|
|
||||||
// determine base vtable size; without that we cannot create the array klasses
|
// determine base vtable size; without that we cannot create the array klasses
|
||||||
compute_base_vtable_size();
|
compute_base_vtable_size();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue