Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8273505: runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java#default-cl crashed with SIGSEGV in MetaspaceShared::link_shared_classes #5566

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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++;
}
}