Skip to content

Commit

Permalink
Merge pull request #21090 from JasonFengJ9/notcheckpointsafe
Browse files Browse the repository at this point in the history
CRIU DeadlockTest adds thread synchronization to prevent premature exit
  • Loading branch information
tajila authored Feb 12, 2025
2 parents 131e430 + 5b5d14e commit 5d76f28
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test/functional/cmdLineTests/criu/criu_nonPortable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
</test>

<test id="Create and Restore Criu Checkpoint Image once - NotCheckpointSafeDeadlock">
<command>bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ -XX:+ThrowOnDelayedCheckpointOperation -Xtrace:print=j9vm.731 --add-opens java.base/jdk.internal.misc=ALL-UNNAMED $STD_CMD_OPTS$" $MAINCLASS_DEADLOCK_TEST$ NotCheckpointSafeDeadlock 1 false false</command>
<command>bash $SCRIPPATH$ $TEST_RESROOT$ $JAVA_COMMAND$ "$JVM_OPTIONS$ -XX:+ThrowOnDelayedCheckpointOperation -Xtrace:print={j9jcl.533,j9vm.684-696,j9vm.699,j9vm.717-743} --add-opens java.base/jdk.internal.misc=ALL-UNNAMED $STD_CMD_OPTS$" $MAINCLASS_DEADLOCK_TEST$ NotCheckpointSafeDeadlock 1 false false</command>
<output type="success" caseSensitive="yes" regex="no">User requested Java dump using</output>
<output type="failure" caseSensitive="yes" regex="no">AOT load and compilation disabled post restore</output>
<output type="success" caseSensitive="yes" regex="no">TEST PASSED</output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public static void checkpointDeadlock() {
}

try {
System.out.println("Pre-checkpoint");
CRIUTestUtils.showThreadCurrentTime("Pre-checkpoint with testResult.lockStatus = "
+ testResult.lockStatus.get());
CRIUTestUtils.checkPointJVM(criuSupport, path, true);
Expand Down Expand Up @@ -161,14 +160,16 @@ public static void notCheckpointSafeDeadlock() {

Thread t1 = new Thread(() -> {
Runnable run = () -> {
CRIUTestUtils.showThreadCurrentTime("notCheckpointSafeDeadlock.t1 started with testResult.lockStatus = "
+ testResult.lockStatus.get());
synchronized (lock) {
testResult.lockStatus.set(1);
try {
Thread.sleep(20000);
} catch (InterruptedException e) {
e.printStackTrace();
CRIUTestUtils.showThreadCurrentTime("notCheckpointSafeDeadlock.t1 locked with testResult.lockStatus = "
+ testResult.lockStatus.get());
// Wait until the lockStatus value is changed.
while (testResult.lockStatus.get() == 1) {
Thread.yield();
}

}
};

Expand All @@ -184,15 +185,26 @@ public static void notCheckpointSafeDeadlock() {
}

try {
System.out.println("Pre-checkpoint");
CRIUTestUtils.showThreadCurrentTime("Pre-checkpoint with testResult.lockStatus = "
+ testResult.lockStatus.get());
CRIUTestUtils.checkPointJVM(criuSupport, path, true);
CRIUTestUtils.showThreadCurrentTime("Post-restore with testResult.lockStatus = "
+ testResult.lockStatus.get());
testResult.testPassed = false;
} catch (JVMCheckpointException e) {
if (!e.getMessage().contains("The JVM attempted to checkpoint but was unable to due to code being executed")) {
CRIUTestUtils.showThreadCurrentTime("notCheckpointSafeDeadlock test failed with testResult.lockStatus = "
+ testResult.lockStatus.get());
testResult.testPassed = false;
e.printStackTrace();
}
}
testResult.lockStatus.set(3);
try {
t1.join();
} catch (InterruptedException e) {
e.printStackTrace();
}

if (testResult.testPassed) {
System.out.println("TEST PASSED");
Expand Down

0 comments on commit 5d76f28

Please sign in to comment.