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

Terminate the thread when unhandled exception happens. #476

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/main/gov/nasa/jpf/vm/ThreadInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2881,14 +2881,10 @@ public Instruction throwException (int exceptionObjRef) {

// there was no overridden uncaughtHandler, or we already executed it
if ("java.lang.ThreadDeath".equals(exceptionName)) { // gracefully shut down
unwindToFirstFrame();
pendingException = null;
return top.getPC().getNext(); // the final DIRECTCALLRETURN

} else { // we have a NoUncaughtPropertyViolation
//NoUncaughtExceptionsProperty.setExceptionInfo(pendingException);
throw new UncaughtException(this, exceptionObjRef);
}
unwindToFirstFrame();
return top.getPC().getNext(); // the final DIRECTCALLRETURN

} else { // we found a matching handler

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gov.nasa.jpf.test.java.concurrent;

import gov.nasa.jpf.util.test.TestJPF;
import org.junit.Test;

public class ThreadExceptionTest extends TestJPF {
@Test
public void testResourceAcquisition() {
if (verifyUnhandledException("java.lang.RuntimeException",
"+search.class=gov.nasa.jpf.search.RandomSearch",
"+cg.randomize_choices=FIXED_SEED", "+search.RandomSearch.path_limit=10", "+search.multiple_errors=true")) {
Thread t = new Thread(() -> {
throw new RuntimeException("Exception from thread");
});
t.start();
}
}
}
Loading