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

8274753: ZGC: SEGV in MetaspaceShared::link_shared_classes #10

Closed
wants to merge 1 commit into from
Closed
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
@@ -550,20 +550,19 @@ void VM_PopulateDumpSharedSpace::doit() {

class CollectCLDClosure : public CLDClosure {
GrowableArray<ClassLoaderData*> _loaded_cld;
GrowableArray<Handle> _loaded_cld_handles; // keep the CLDs alive
GrowableArray<OopHandle> _loaded_cld_handles; // keep the CLDs alive
Thread* _current_thread;
public:
CollectCLDClosure(Thread* thread) : _current_thread(thread) {}
~CollectCLDClosure() {
for (int i = 0; i < _loaded_cld.length(); i++) {
ClassLoaderData* cld = _loaded_cld.at(i);
for (int i = 0; i < _loaded_cld_handles.length(); i++) {
_loaded_cld_handles.at(i).release(Universe::vm_global());
}
}
void do_cld(ClassLoaderData* cld) {
if (!cld->is_unloading()) {
_loaded_cld.append(cld);
_loaded_cld_handles.append(Handle(_current_thread, cld->holder_phantom()));
}
assert(cld->is_alive(), "must be");
_loaded_cld.append(cld);
_loaded_cld_handles.append(OopHandle(Universe::vm_global(), cld->holder_phantom()));
}

int nof_cld() const { return _loaded_cld.length(); }
@@ -55,6 +55,7 @@
#include "classfile/packageEntry.hpp"
#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/systemDictionaryShared.hpp"
#include "classfile/vmClasses.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
@@ -886,6 +887,8 @@ void ClassLoaderData::free_deallocate_list_C_heap_structures() {
// Remove the class so unloading events aren't triggered for
// this class (scratch or error class) in do_unloading().
remove_class(ik);
// But still have to remove it from the dumptime_table.
SystemDictionaryShared::handle_class_unloading(ik);
}
}
}
@@ -52,6 +52,23 @@
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicLoaderConstraintsTest custom
*/

/**
* @test id=custom-cl-zgc
* @requires vm.cds.custom.loaders
* @requires vm.gc.Z
* @summary Test dumptime_table entries are removed with zgc eager class unloading
* @bug 8274935
* @library /test/lib
* /test/hotspot/jtreg/runtime/cds/appcds
* /test/hotspot/jtreg/runtime/cds/appcds/test-classes
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive
* @modules java.base/jdk.internal.misc
* jdk.httpserver
* @build sun.hotspot.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm/timeout=180 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicLoaderConstraintsTest custom-zgc
*/

import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import jdk.test.lib.Asserts;
@@ -83,9 +100,11 @@ public class DynamicLoaderConstraintsTest extends DynamicArchiveTestBase {
* if false, LoaderConstraintsApp will be loaded by the built-in AppClassLoader.
*/
static boolean useCustomLoader;
static boolean useZGC;

public static void main(String[] args) throws Exception {
useCustomLoader = (args.length != 0);
useZGC = (args.length != 0 && args[0].equals("custom-zgc"));
runTest(DynamicLoaderConstraintsTest::doTest);
}

@@ -124,8 +143,15 @@ static void doTest(boolean errorInDump) throws Exception {
};

if (useCustomLoader) {
cmdLine = TestCommon.concat(cmdLine, "-cp", loaderJar,
loaderMainClass, appJar);
if (useZGC) {
// Add options to force eager class unloading.
cmdLine = TestCommon.concat(cmdLine, "-cp", loaderJar,
"-XX:+UseZGC", "-XX:ZCollectionInterval=0.01",
loaderMainClass, appJar);
} else {
cmdLine = TestCommon.concat(cmdLine, "-cp", loaderJar,
loaderMainClass, appJar);
}
} else {
cmdLine = TestCommon.concat(cmdLine, "-cp", appJar);
}