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

Ioi Lam iklam at openjdk.org
Thu May 29 20:49:53 UTC 2025


On Thu, 29 May 2025 20:16:43 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> 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
>
> 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.

`Exception::log_exception()` cannot handle the other two cases. 

One case is exception thrown in native code. They look like this in the log. Notice the reference to the C++ source code. These stack traces are useful for JVM developers.


[2.104s][info ][exceptions] Exception <a 'java/lang/NullPointerException'{0x00000004736ab0b0}> (0x00000004736ab0b0) 
[                         ] thrown [/jdk3/zoo/open/src/hotspot/share/interpreter/linkResolver.cpp, line 1522]
[                         ] for thread 0x0000716be002e7b0
[2.104s][trace][exceptions] 	at jdk.internal.logger.AbstractLoggerWrapper.isLoggable(java.base at 25-internal/AbstractLoggerWrapper.java:68)
[2.104s][trace][exceptions] 	at java.lang.ProcessBuilder.start(java.base at 25-internal/ProcessBuilder.java:1093)
[2.104s][trace][exceptions] 	at java.lang.ProcessBuilder.start(java.base at 25-internal/ProcessBuilder.java:1044)
[2.104s][trace][exceptions] 	at jdk.internal.misc.CDS$ProcessLauncher.execWithJavaToolOptions(java.base at 25-internal/CDS.java:548)


The other case is when the exception cannot be allocated. Again, the log message is different.

I didn't want to rearrange the existing code, so I just added a call to `maybe_log_call_stack()` in whenever we print `"Exception <"` to the `exceptions` log.

I added a test for when `Exception::log_exception()` is called, but I don't know how to test the other two cases easily.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25522#discussion_r2114725814


More information about the hotspot-dev mailing list