8222936: mlvm/anonloader/stress/randomBytecodes/Test.java fails due to "ERROR: There were 1 hangups during parsing."
Prevent false failures by blocking the test until either it times out or the loading thread finishes Reviewed-by: dholmes, coleenp
This commit is contained in:
parent
913ab5c6f4
commit
1b0445639f
@ -27,6 +27,7 @@ import java.io.File;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import nsk.share.test.Stresser;
|
import nsk.share.test.Stresser;
|
||||||
import vm.share.options.Option;
|
import vm.share.options.Option;
|
||||||
@ -75,7 +76,7 @@ import vm.share.UnsafeAccess;
|
|||||||
*/
|
*/
|
||||||
public abstract class StressClassLoadingTest extends MlvmTest {
|
public abstract class StressClassLoadingTest extends MlvmTest {
|
||||||
private static final String RESCUE_FILE_NAME = "_AnonkTestee01.class";
|
private static final String RESCUE_FILE_NAME = "_AnonkTestee01.class";
|
||||||
private static final String HUNG_CLASS_FILE_NAME = "hang%02d.class";
|
private static final String HUNG_CLASS_FILE_NAME = "hang.class";
|
||||||
|
|
||||||
@Option(name = "iterations", default_value = "100000",
|
@Option(name = "iterations", default_value = "100000",
|
||||||
description = "How many times generate a class and parse it")
|
description = "How many times generate a class and parse it")
|
||||||
@ -135,8 +136,6 @@ public abstract class StressClassLoadingTest extends MlvmTest {
|
|||||||
public boolean run() throws Exception {
|
public boolean run() throws Exception {
|
||||||
setupOptions(this);
|
setupOptions(this);
|
||||||
|
|
||||||
int hangNum = 0;
|
|
||||||
|
|
||||||
Stresser stresser = createStresser();
|
Stresser stresser = createStresser();
|
||||||
stresser.start(iterations);
|
stresser.start(iterations);
|
||||||
|
|
||||||
@ -176,39 +175,39 @@ public abstract class StressClassLoadingTest extends MlvmTest {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
parserThread.setDaemon(true);
|
|
||||||
parserThread.start();
|
parserThread.start();
|
||||||
parserThread.join(parseTimeout);
|
parserThread.join(parseTimeout);
|
||||||
|
|
||||||
if (parserThread.isAlive()) {
|
if (parserThread.isAlive()) {
|
||||||
Env.complain("Killing parser thread");
|
Env.traceImportant("parser thread may be hung!");
|
||||||
StackTraceElement[] stack = parserThread.getStackTrace();
|
StackTraceElement[] stack = parserThread.getStackTrace();
|
||||||
|
Env.traceImportant("parser thread stack len: " + stack.length);
|
||||||
Env.traceImportant(parserThread + " stack trace:");
|
Env.traceImportant(parserThread + " stack trace:");
|
||||||
for (int i = 0; i < stack.length; ++i) {
|
for (int i = 0; i < stack.length; ++i) {
|
||||||
Env.traceImportant(parserThread + "\tat " + stack[i]);
|
Env.traceImportant(parserThread + "\tat " + stack[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Path savedClassPath = Paths.get(fileNamePrefix + HUNG_CLASS_FILE_NAME);
|
||||||
|
|
||||||
if (saveClassFile) {
|
if (saveClassFile) {
|
||||||
Files.move(rescueFile.toPath(), Paths.get(fileNamePrefix
|
Files.move(rescueFile.toPath(), savedClassPath);
|
||||||
+ String.format(HUNG_CLASS_FILE_NAME, hangNum)));
|
Env.traceImportant("There was a possible hangup during parsing."
|
||||||
|
+ " The class file, which produced the possible hangup, was saved as "
|
||||||
|
+ fileNamePrefix + HUNG_CLASS_FILE_NAME
|
||||||
|
+ "... in the test directory. You may want to analyse it "
|
||||||
|
+ "if this test times out.");
|
||||||
|
}
|
||||||
|
|
||||||
|
parserThread.join(); // Wait until either thread finishes or test times out.
|
||||||
|
if (saveClassFile) {
|
||||||
|
savedClassPath.toFile().delete();
|
||||||
}
|
}
|
||||||
++hangNum;
|
|
||||||
} else if (saveClassFile) {
|
} else if (saveClassFile) {
|
||||||
rescueFile.delete();
|
rescueFile.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stresser.finish();
|
stresser.finish();
|
||||||
|
|
||||||
if (hangNum > 0) {
|
|
||||||
Env.complain("There were " + hangNum + " hangups during parsing."
|
|
||||||
+ " The class files, which produced hangup were saved as "
|
|
||||||
+ fileNamePrefix + String.format(HUNG_CLASS_FILE_NAME, 0)
|
|
||||||
+ "... in the test directory. You may want to analyse them."
|
|
||||||
+ " Failing this test because of hangups.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user