RFR: 8358080: Print thread stack with -Xlog:exceptions=trace [v2]
Coleen Phillimore
coleenp at openjdk.org
Thu May 29 20:19:52 UTC 2025
On Thu, 29 May 2025 19:50:08 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)
>
> Ioi Lam has updated the pull request incrementally with one additional commit since the last revision:
>
> Cover more cases where an exception can be thrown
Changes requested by coleenp (Reviewer).
src/hotspot/share/utilities/exceptions.cpp line 126:
> 124: p2i(h_exception()), file, line, p2i(thread),
> 125: Universe::vm_exception()->print_value_string());
> 126: maybe_log_call_stack();
This can't be coming from Java code, so don't log it here. This is actually the compiler thread case that we should probably log the native stack trace for [JDK-8328639](https://bugs.openjdk.org/browse/JDK-8328639)
src/hotspot/share/utilities/exceptions.cpp line 156:
> 154: MAX_LEN, message ? message : "",
> 155: p2i(h_exception()), file, line, p2i(thread));
> 156: maybe_log_call_stack();
Why doesn't this call log_exception? If you're going to add this place, you probably should add a test case. I think the first change where you added to log_exception was the best version, and there is a logging test case for that you could improve.
-------------
PR Review: https://git.openjdk.org/jdk/pull/25522#pullrequestreview-2879495500
PR Review Comment: https://git.openjdk.org/jdk/pull/25522#discussion_r2114678139
PR Review Comment: https://git.openjdk.org/jdk/pull/25522#discussion_r2114682962
More information about the hotspot-dev
mailing list