RFR: 8358080: Print thread stack with -Xlog:exceptions=trace

Coleen Phillimore coleenp at openjdk.org
Thu May 29 18:42:51 UTC 2025


On Thu, 29 May 2025 16:39:44 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> This makes it easier to analyze exceptions without modifying the JVM or the app to print call stacks:
> 
> 
> $ java -Xlog:exceptions=trace -cp foo.jar Foo
> [2.047s][info ][exceptions] Exception <a 'java/lang/NullPointerException'{0x00000004736ab200}>
> [ ] thrown in interpreter method <{method} {0x000070488c9f2a50} 'isLoggable' '(Ljava/lang/System$Logger$Level;)Z' in 'jdk/internal/logger/AbstractLoggerWrapper'>
> [ ] at bci 5 for thread 0x000070499802e730 (DestroyJavaVM)
> [2.048s][trace][exceptions] at jdk.internal.logger.AbstractLoggerWrapper.isLoggable([java.base at 25-internal](mailto:java.base at 25-internal)/AbstractLoggerWrapper.java:68)
> [2.048s][trace][exceptions] at java.lang.ProcessBuilder.start([java.base at 25-internal](mailto:java.base at 25-internal)/ProcessBuilder.java:1093)
> [2.048s][trace][exceptions] at java.lang.ProcessBuilder.start([java.base at 25-internal](mailto:java.base at 25-internal)/ProcessBuilder.java:1044)
> [2.048s][trace][exceptions] at jdk.internal.misc.CDS$ProcessLauncher.execWithJavaToolOptions([java.base at 25-internal](mailto:java.base at 25-internal)/CDS.java:548)

This looks good although running some tests with -Xlog:exceptions=trace would be good.  The java stack should be stable.  Also I was worried about this printing/hanging for StackOverflowError but print_stack_on() limits to MaxJavaStackTraceDepth=1024.

Marked as reviewed by coleenp (Reviewer).

src/hotspot/share/utilities/exceptions.cpp line 615:

> 613:     Thread* t = Thread::current_or_null();
> 614:     if (t != nullptr && t->is_Java_thread()) { // sanity
> 615:       JavaThread *jt = JavaThread::current();

star on the wrong side.

-------------

PR Review: https://git.openjdk.org/jdk/pull/25522#pullrequestreview-2879255716
PR Review: https://git.openjdk.org/jdk/pull/25522#pullrequestreview-2879263314
PR Review Comment: https://git.openjdk.org/jdk/pull/25522#discussion_r2114532980


More information about the hotspot-dev mailing list