8273505: runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java#default-cl crashed with SIGSEGV in MetaspaceShared::link_shared_classes
Reviewed-by: iklam, minqi
This commit is contained in:
parent
26e5e9ae8c
commit
a67f0f9dc0
src/hotspot/share
@ -584,18 +584,19 @@ void VM_PopulateDumpSharedSpace::doit() {
|
||||
|
||||
class CollectCLDClosure : public CLDClosure {
|
||||
GrowableArray<ClassLoaderData*> _loaded_cld;
|
||||
GrowableArray<Handle> _loaded_cld_handles; // keep the CLDs alive
|
||||
Thread* _current_thread;
|
||||
public:
|
||||
CollectCLDClosure() {}
|
||||
CollectCLDClosure(Thread* thread) : _current_thread(thread) {}
|
||||
~CollectCLDClosure() {
|
||||
for (int i = 0; i < _loaded_cld.length(); i++) {
|
||||
ClassLoaderData* cld = _loaded_cld.at(i);
|
||||
cld->dec_keep_alive();
|
||||
}
|
||||
}
|
||||
void do_cld(ClassLoaderData* cld) {
|
||||
if (!cld->is_unloading()) {
|
||||
cld->inc_keep_alive();
|
||||
_loaded_cld.append(cld);
|
||||
_loaded_cld_handles.append(Handle(_current_thread, cld->holder_phantom()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -641,11 +642,10 @@ bool MetaspaceShared::link_class_for_cds(InstanceKlass* ik, TRAPS) {
|
||||
}
|
||||
|
||||
void MetaspaceShared::link_shared_classes(TRAPS) {
|
||||
// Collect all loaded ClassLoaderData.
|
||||
ResourceMark rm;
|
||||
|
||||
LambdaFormInvokers::regenerate_holder_classes(CHECK);
|
||||
CollectCLDClosure collect_cld;
|
||||
|
||||
// Collect all loaded ClassLoaderData.
|
||||
CollectCLDClosure collect_cld(THREAD);
|
||||
{
|
||||
// ClassLoaderDataGraph::loaded_cld_do requires ClassLoaderDataGraph_lock.
|
||||
// We cannot link the classes while holding this lock (or else we may run into deadlock).
|
||||
|
@ -302,9 +302,7 @@ bool ClassLoaderData::try_claim(int claim) {
|
||||
// it is being defined, therefore _keep_alive is not volatile or atomic.
|
||||
void ClassLoaderData::inc_keep_alive() {
|
||||
if (has_class_mirror_holder()) {
|
||||
if (!Arguments::is_dumping_archive()) {
|
||||
assert(_keep_alive > 0, "Invalid keep alive increment count");
|
||||
}
|
||||
assert(_keep_alive > 0, "Invalid keep alive increment count");
|
||||
_keep_alive++;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user