mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8193053: jvm crash by G1CMBitMapClosure::do_addr
We were adding an unloaded mirror to the SATB collection set in remove_handle. Reviewed-by: hseigel, kbarrett
This commit is contained in:
parent
16d95cbf9d
commit
3541733024
2 changed files with 30 additions and 4 deletions
|
@ -574,9 +574,9 @@ void ClassLoaderData::unload() {
|
||||||
ls.cr();
|
ls.cr();
|
||||||
}
|
}
|
||||||
|
|
||||||
// In some rare cases items added to this list will not be freed elsewhere.
|
// Some items on the _deallocate_list need to free their C heap structures
|
||||||
// To keep it simple, just free everything in it here.
|
// if they are not already on the _klasses list.
|
||||||
free_deallocate_list();
|
unload_deallocate_list();
|
||||||
|
|
||||||
// Clean up global class iterator for compiler
|
// Clean up global class iterator for compiler
|
||||||
static_klass_iterator.adjust_saved_class(this);
|
static_klass_iterator.adjust_saved_class(this);
|
||||||
|
@ -755,6 +755,7 @@ OopHandle ClassLoaderData::add_handle(Handle h) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClassLoaderData::remove_handle(OopHandle h) {
|
void ClassLoaderData::remove_handle(OopHandle h) {
|
||||||
|
assert(!is_unloading(), "Do not remove a handle for a CLD that is unloading");
|
||||||
oop* ptr = h.ptr_raw();
|
oop* ptr = h.ptr_raw();
|
||||||
if (ptr != NULL) {
|
if (ptr != NULL) {
|
||||||
assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
|
assert(_handles.contains(ptr), "Got unexpected handle " PTR_FORMAT, p2i(ptr));
|
||||||
|
@ -799,6 +800,7 @@ void ClassLoaderData::add_to_deallocate_list(Metadata* m) {
|
||||||
void ClassLoaderData::free_deallocate_list() {
|
void ClassLoaderData::free_deallocate_list() {
|
||||||
// Don't need lock, at safepoint
|
// Don't need lock, at safepoint
|
||||||
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
||||||
|
assert(!is_unloading(), "only called for ClassLoaderData that are not unloading");
|
||||||
if (_deallocate_list == NULL) {
|
if (_deallocate_list == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -828,6 +830,29 @@ void ClassLoaderData::free_deallocate_list() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is distinct from free_deallocate_list. For class loader data that are
|
||||||
|
// unloading, this frees the C heap memory for constant pools on the list. If there
|
||||||
|
// were C heap memory allocated for methods, it would free that too. The C heap memory
|
||||||
|
// for InstanceKlasses on this list is freed in the ClassLoaderData destructor.
|
||||||
|
void ClassLoaderData::unload_deallocate_list() {
|
||||||
|
// Don't need lock, at safepoint
|
||||||
|
assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
|
||||||
|
assert(is_unloading(), "only called for ClassLoaderData that are unloading");
|
||||||
|
if (_deallocate_list == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Go backwards because this removes entries that are freed.
|
||||||
|
for (int i = _deallocate_list->length() - 1; i >= 0; i--) {
|
||||||
|
Metadata* m = _deallocate_list->at(i);
|
||||||
|
assert (!m->on_stack(), "wouldn't be unloading if this were so");
|
||||||
|
_deallocate_list->remove_at(i);
|
||||||
|
// Only constant pool entries have C heap memory to free.
|
||||||
|
if (m->is_constantPool()) {
|
||||||
|
((ConstantPool*)m)->release_C_heap_structures();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// These anonymous class loaders are to contain classes used for JSR292
|
// These anonymous class loaders are to contain classes used for JSR292
|
||||||
ClassLoaderData* ClassLoaderData::anonymous_class_loader_data(oop loader, TRAPS) {
|
ClassLoaderData* ClassLoaderData::anonymous_class_loader_data(oop loader, TRAPS) {
|
||||||
// Add a new class loader data to the graph.
|
// Add a new class loader data to the graph.
|
||||||
|
|
|
@ -307,7 +307,8 @@ class ClassLoaderData : public CHeapObj<mtClass> {
|
||||||
void packages_do(void f(PackageEntry*));
|
void packages_do(void f(PackageEntry*));
|
||||||
|
|
||||||
// Deallocate free list during class unloading.
|
// Deallocate free list during class unloading.
|
||||||
void free_deallocate_list();
|
void free_deallocate_list(); // for the classes that are not unloaded
|
||||||
|
void unload_deallocate_list(); // for the classes that are unloaded
|
||||||
|
|
||||||
// Allocate out of this class loader data
|
// Allocate out of this class loader data
|
||||||
MetaWord* allocate(size_t size);
|
MetaWord* allocate(size_t size);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue