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

8267404: vmTestbase/vm/mlvm/anonloader/stress/oome/metaspace/Test.java failed with OutOfMemoryError #4140

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
1 change: 0 additions & 1 deletion test/hotspot/jtreg/ProblemList.txt
Expand Up @@ -154,7 +154,6 @@ vmTestbase/vm/mlvm/meth/stress/jdi/breakpointInCompiledCode/Test.java 8257761 ge
vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2none_a/TestDescription.java 8013267 generic-all
vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manyDiff_b/TestDescription.java 8013267 generic-all
vmTestbase/vm/mlvm/indy/func/jvmti/mergeCP_indy2manySame_b/TestDescription.java 8013267 generic-all
vmTestbase/vm/mlvm/anonloader/stress/oome/metaspace/Test.java 8267404 linux-aarch64

vmTestbase/nsk/jdwp/ThreadReference/ForceEarlyReturn/forceEarlyReturn001/forceEarlyReturn001.java 7199837 generic-all

Expand Down
Expand Up @@ -24,69 +24,38 @@

/*
* @test
* @modules java.base/jdk.internal.misc
*
* @summary converted from VM Testbase vm/mlvm/anonloader/stress/oome/metaspace.
* VM Testbase keywords: [feature_mlvm, nonconcurrent]
*
* @library /vmTestbase
* /test/lib
* @library /test/lib
*
* @comment build test class and indify classes
* @build vm.mlvm.anonloader.stress.oome.metaspace.Test
* @run driver vm.mlvm.share.IndifiedClassesBuilder
*
* @run main/othervm -Xmx256m -XX:-UseGCOverheadLimit -XX:MaxMetaspaceSize=8m vm.mlvm.anonloader.stress.oome.metaspace.Test
* @run driver vm.mlvm.anonloader.stress.oome.metaspace.Test
*/

package vm.mlvm.anonloader.stress.oome.metaspace;

import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandles.Lookup;
import java.util.List;
import java.io.IOException;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

import vm.mlvm.anonloader.share.AnonkTestee01;
import vm.mlvm.share.MlvmOOMTest;
import vm.mlvm.share.MlvmTestExecutor;
import vm.mlvm.share.Env;
import vm.share.FileUtils;
public class Test {

/**
* This test loads classes using defineHiddenClass and stores them,
* expecting Metaspace OOME.
*
*/
public class Test extends MlvmOOMTest {
@Override
protected void checkOOME(OutOfMemoryError oome) {
String message = oome.getMessage();
if (!"Metaspace".equals(message) && !"Compressed class space".equals(message)) {
throw new RuntimeException("TEST FAIL : wrong OOME", oome);
public static void main(String[] args) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-Xshare:off", "-XX:MaxMetaspaceSize=100k", "-version");

OutputAnalyzer analyzer = new OutputAnalyzer(pb.start());

analyzer.shouldNotHaveExitValue(0);

if (!analyzer.getStdout().contains("OutOfMemoryError")) {
throw new RuntimeException("TEST FAIL : no OOME");
}
}

@Override
protected void eatMemory(List<Object> list) {
byte[] classBytes = null;
try {
classBytes = FileUtils.readClass(AnonkTestee01.class.getName());
} catch (IOException e) {
Env.throwAsUncheckedException(e);
if (!analyzer.getStdout().contains("Metaspace") &&
!analyzer.getStdout().contains("Compressed class space")) {
throw new RuntimeException("TEST FAIL : wrong OOME");
}
try {
while (true) {
Lookup lookup = MethodHandles.lookup();
Lookup ank_lookup = MethodHandles.privateLookupIn(AnonkTestee01.class, lookup);
Class<?> c = ank_lookup.defineHiddenClass(classBytes, true).lookupClass();
list.add(c.newInstance());
}
} catch (InstantiationException | IllegalAccessException e) {
Env.throwAsUncheckedException(e);
}
}

public static void main(String[] args) {
MlvmTestExecutor.launch(args);
}
}