Skip to content
Permalink
Browse files
8273505: runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraint…
…sTest.java#default-cl crashed with SIGSEGV in MetaspaceShared::link_shared_classes

Reviewed-by: ccheung
Backport-of: a67f0f9dc04200c22db05e277346f24d31306b53
  • Loading branch information
Harold Seigel committed Oct 14, 2021
1 parent e79cb9c commit aabc4ba0eef9e47fc547b4ec91153a9427acd968
Showing 2 changed files with 8 additions and 10 deletions.
@@ -550,18 +550,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()));
}
}

@@ -591,11 +592,10 @@ bool MetaspaceShared::link_class_for_cds(InstanceKlass* ik, TRAPS) {
}

void MetaspaceShared::link_and_cleanup_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++;
}
}

1 comment on commit aabc4ba

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on aabc4ba Oct 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.