Browse Source

PrismCL: Special handling for stack overflow

If we catch a StackOverflowError, we now print a (limited) stack trace
and additionally provide a hint regarding the use of the -javastack
argument.
master
Joachim Klein 8 years ago
committed by Dave Parker
parent
commit
530c981092
  1. 19
      prism/src/prism/PrismCL.java

19
prism/src/prism/PrismCL.java

@ -35,6 +35,7 @@ import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import common.StackTraceHelper;
import parser.Values;
import parser.ast.Expression;
import parser.ast.ExpressionReward;
@ -220,14 +221,20 @@ public class PrismCL implements PrismModelListener
// we don't want to catch the nailgun exception below,
// so we catch it and rethrow
throw e;
} catch (Exception e) {
// We catch Exceptions here ourself to ensure that we actually exit
} catch (Exception|StackOverflowError e) {
// We catch Exceptions/stack overflows here ourself to ensure that we actually exit
// In the presence of thread pools (e.g., in the JAS library when using -exact),
// the main thread dying does not necessarily quit the program...
StringWriter sw = new StringWriter();
sw.append("\n");
e.printStackTrace(new PrintWriter(sw));
mainLog.print(sw.toString());
mainLog.println();
if (e instanceof StackOverflowError) {
// print exception + limited stack trace for stack overflows
mainLog.println(e.toString());
mainLog.println(StackTraceHelper.asString(e, StackTraceHelper.DEFAULT_STACK_TRACE_LIMIT));
mainLog.println("Try increasing the value of the Java stack size (via the -javastack argument).");
} else {
// print exception + full stack trace for generic exceptions
mainLog.print(e.toString() + "\n" + StackTraceHelper.asString(e, 0));
}
errorAndExit("Caught unhandled exception, aborting...");
}
}

Loading…
Cancel
Save