printStackTrace output limit?
843810Jan 13 2003 — edited Jan 14 2003Is there an upper bound limit on the amount of output data issued by a call to the Exception class' printStackTrace method?
Is the upper bound limit 64k bytes?
Is there a workaround or configuration property to increase this upper bound without resorting to overloading or subclassing the Exception class?
I recently resolved a recursion problem in a Java application which encountered JVM behavior similar to Bud Id 4402735. This describes a case where the first stack overflow is detected, but subsequent stack overflows result in a fatal segmentation fault.
Despite the use of values > 512k supplied to the "-Xss<stacksize>" option of a Java 1.3.1 based application, the Exception.printStackTrace method appears to only print a limited amount of output when it is called to report a stack overflow exception. Decreasing the stack space allocation results in a shorter report as expected. Comparing the depths of the stack frame depth in the errant thread in the resultant core file when various -Xss values are applied confirms that more -Xss allocation results in more recursion and thus deeper stack frames. However, the printStackTrace output levels off at 1024 lines of output for a simple recursive test (see below). For most simple cases of recursion, this probably is ample information. For more complex issues, involving a long repeating pattern, or to convince non-believers, it may be beneficial to have a complete stack trace. While dbx(1) demonstrates the true depth of recursion found in the core file, the logic surrounding the cause of the problem is typically not mappable to the originating Java source.
Any pointers would greatly be appreciated.
Cheers,
Click
//Simple recursion test demonstrating BugID 4402735
The test program below generates the following results.
bash-2.03$ java -Xss512k test 2>&1 | grep -c 'at test.runner'
1024
Abort (core dumped)
bash-2.03$ java -Xss128k test 2>&1 | grep -c 'at test.runner'
776
Abort (core dumped)
bash-2.03$ java -Xss512k test 2>&1 | grep -c 'at test.runner'
1024
Abort (core dumped)
bash-2.03$ java -Xss1024k test 2>&1 | grep -c 'at test.runner'
1024
Abort (core dumped)
bash-2.03$ java -Xss2048k test 2>&1 | grep -c 'at test.runner'
1024
Abort (core dumped)
bash-2.03$
public class test {
public static void main(String[] args) {
overflow("First overflow");
overflow("Second overflow");
}
static void runner() {
runner();
}
static void overflow(String msg) {
try {
runner();
} catch (StackOverflowError e) {
System.out.println(msg);
e.printStackTrace();
System.out.flush();
}
}
}