Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show entire stack trace even in a stack overflow error

By default, when a Java program (in this case I'm just talking about a simple commandline program, no extra frameworks or anything) crashes, the exception prints a stack trace, which is helpful.

However, in the case of a stack overflow error, it seems the depth goes over some arbitrary limit, because the trace gets cut off; the upshot is that I only get to see the (long list of repeats of) the code that fell into the infinite recursion, and not the calling code that set up the conditions for it, which is what I need to track down the bug I am currently looking at.

Is there a way to tell the JVM 'print the entire stack trace, I don't care how long it is'?

like image 303
rwallace Avatar asked Mar 05 '26 21:03

rwallace


1 Answers

Run java -XX:MaxJavaStackTraceDepth=999999

The default limit is 1024.

like image 154
apangin Avatar answered Mar 07 '26 09:03

apangin