Skip to content
Permalink
Browse files
8274753: ZGC: SEGV in MetaspaceShared::link_shared_classes
8274935: dumptime_table has stale entry

Reviewed-by: eosterlund, iklam
  • Loading branch information
coleenp committed Oct 11, 2021
1 parent b7af890 commit 110e38ded8e09361f24c582c770d35f5cfdabf82
Showing 3 changed files with 37 additions and 9 deletions.
@@ -584,20 +584,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"
@@ -884,6 +885,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/timeout=180 -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);
}

5 comments on commit 110e38d

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 110e38d Oct 11, 2021

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 110e38d Dec 20, 2021

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 110e38d Dec 20, 2021

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-110e38de in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 110e38de from the openjdk/jdk repository.

The commit being backported was authored by Coleen Phillimore on 11 Oct 2021 and was reviewed by Erik Österlund and Ioi Lam.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-110e38de:GoeLin-backport-110e38de
$ git checkout GoeLin-backport-110e38de
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-110e38de

@tstuefe
Copy link
Member

@tstuefe tstuefe commented on 110e38d Jan 24, 2022

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 110e38d Jan 24, 2022

Choose a reason for hiding this comment

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

@tstuefe the backport was successfully created on the branch tstuefe-backport-110e38de in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 110e38de from the openjdk/jdk repository.

The commit being backported was authored by Coleen Phillimore on 11 Oct 2021 and was reviewed by Erik Österlund and Ioi Lam.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev tstuefe-backport-110e38de:tstuefe-backport-110e38de
$ git checkout tstuefe-backport-110e38de
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev tstuefe-backport-110e38de

Please sign in to comment.