Skip to content

Commit

Permalink
Do not crash when encountering empty stack traces
Browse files Browse the repository at this point in the history
Recent JVMs run with OmitStackTraceInFastThrow enabled by default. When
an exception occurs several times, the stack trace is no more generated,
but COSBench still tries to parse it, and fails miserably. One solution
is to run COSBench with -XX:-OmitStackTraceInFastThrow. For extra
security we will also ignore such empty stack traces.

Fixes: intel-cloud#323
Fixes: intel-cloud#331
  • Loading branch information
fvennetier committed Jan 3, 2020
1 parent e542830 commit e212bd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,15 @@ protected static void doLogErr(Logger logger, String message, Exception e) {
protected abstract void operate(int idx, int all, Session session);

public static void errorStatisticsHandle(Exception e, Session session, String target){
String trace = e.getStackTrace()[0].toString();
trace = e.getCause() == null ? trace : trace + e.getCause().getStackTrace()[0].toString();
String trace = null;
try {
trace = e.getStackTrace()[0].toString();
trace = e.getCause() == null ? trace : trace + e.getCause().getStackTrace()[0].toString();
} catch (ArrayIndexOutOfBoundsException ignored) {
LOGGER.debug("Got an error with an empty stack trace. " +
"Run the driver with -XX:-OmitStackTraceInFastThrow to prevent this.", e);
trace = "<undefined>";
}
ErrorStatistics errorStatistics = session.getErrorStatistics();
HashMap<String, String> stackTraceAndTargets = errorStatistics.getStackTraceAndTargets();
synchronized (stackTraceAndTargets) {
Expand Down
2 changes: 1 addition & 1 deletion release/cosbench-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ mkdir -p log

echo "Launching osgi framwork ... "

/usr/bin/nohup java -Dcosbench.tomcat.config=$TOMCAT_CONFIG -server -cp main/* org.eclipse.equinox.launcher.Main -configuration $OSGI_CONFIG -console $OSGI_CONSOLE_PORT 1> $BOOT_LOG 2>&1 &
/usr/bin/nohup java -XX:-OmitStackTraceInFastThrow -Dcosbench.tomcat.config=$TOMCAT_CONFIG -server -cp main/* org.eclipse.equinox.launcher.Main -configuration $OSGI_CONFIG -console $OSGI_CONSOLE_PORT 1> $BOOT_LOG 2>&1 &

if [ $? -ne 0 ];
then
Expand Down

0 comments on commit e212bd7

Please sign in to comment.