RFR: 8359120: Improve warning message when fail to load hsdis library
Manuel Hässig
mhaessig at openjdk.org
Thu Jun 19 09:34:22 UTC 2025
On Tue, 10 Jun 2025 13:38:03 GMT, Taizo Kurashige <tkurashige at openjdk.org> wrote:
> This PR is improvement of warning message when fail to load hsdis library.
>
> [JDK-8287001](https://bugs.openjdk.org/browse/JDK-8287001) introduced a warning on hsdis library load failure. This is useful when the user executes -XX:+PrintAssembly, etc.
>
> However, I think that when hs_err occurs, users might be confused by this warning printed by Xlog. Because users are not likely to know that hsdis is loaded for the [MachCode] section of the hs_err report, they may wonder, for example, "Why do I get warnings about hsdis load errors when -XX:+PrintAssembly is not specified?."
>
> To clear up this confusion, I suggest printing a warning just before [MachCode].
>
> <details>
>
> <summary>sample output</summary>
>
> If hs_err occurs and hsdis load fails without the option to specify where the hs_err report should be output, the following is output to the hs_err_pir log file:
>
> .
> .
> native method entry point (kind = native) [0x000001ae8753cec0, 0x000001ae8753dac0] 3072 bytes
>
> Loading hsdis library failed, so undisassembled code is printed in the below [MachCode] section
> [MachCode]
> 0x000001ae8753cec0: 488b 4b08 | 0fb7 492e | 584c 8d74 | ccf8 6800 | 0000 0068 | 0000 0000 | 5055 488b | ec41 5548
> 0x000001ae8753cee0: 8b43 084c | 8d68 3848 | 8b40 0868 | 0000 0000 | 5348 8b50 | 18
> .
> .
>
>
> If -XX:+PrintAssembly is specified and hsdis load fails, the following is output to the stdout
>
> $ java -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly -version
> OpenJDK 64-Bit Server VM warning: PrintAssembly is enabled; turning on DebugNonSafepoints to gain additional output
>
> ============================= C1-compiled nmethod ==============================
> ----------------------------------- Assembly -----------------------------------
>
> Compiled method (c1) 57 2 3 java.lang.Object::<init> (1 bytes)
> total in heap [0x0000024a08a00008,0x0000024a08a00208] = 512
> .
> .
>
> [Constant Pool (empty)]
>
>
> Loading hsdis library failed, so undisassembled code is printed in the below [MachCode] section
> [MachCode]
> [Instructions begin]
> 0x0000024a08a00100: 6666 660f | 1f84 0000 | 0000 0066 | 6666 9066 | 6690 448b | 5208 443b
> .
> .
> [Constant Pool (empty)]
>
>
> Loading hsdis library failed, so undisassembled code is printed in the below [MachCode] section
> [MachCode]
> [Verified Entry Point]
> # {method} {0x00000000251a1898} 'toUnsignedInt' '(B)I' in 'java/lang/Byte
> .
> .
>
>
> </details>
>
> Since the warning added in this fix cover the role of warning introduced in [JDK-8287001](https://bugs.openjdk.org/browse/JDK-828...
Thank you for working on this. I have been confused by this myself and think this is a great improvement. I do have a few comments and questions, though.
Currently, I do not understand exactly how your new message is only printed when hsdis is not loaded. Do we only emit a MachCode section if hsdis is not loaded?
src/hotspot/share/code/nmethod.cpp line 3493:
> 3491: st->bol();
> 3492: st->cr();
> 3493: st->print_cr("Loading hsdis library failed, so undisassembled code is printed in the below [MachCode] section");
Some comments on the message:
- I don't think we should use `[MachCode]` inside the square brackets apart from marking the start of a section. Otherwise, tools parsing a hs_err file incorrectly identify the start of the MachCode section.
- Personally, I find the language of the message a bit clunky. Here are a few suggestions I would personally prefer:
`Loading hsdis library failed, unable to show disassembled code in MachCode section` or `Note: Unable to display disassembled code because loading of hsdis library failed.`.
src/hotspot/share/compiler/disassembler.cpp line 841:
> 839: os::dll_lookup(_library, decode_instructions_virtual_name));
> 840: } else {
> 841: log_warning(os)("Loading hsdis library failed");
Personally, I would leave this warning. It does not hurt, and perhaps someone is depending on it to detect if hsdis is installed correctly.
-------------
Changes requested by mhaessig (Author).
PR Review: https://git.openjdk.org/jdk/pull/25726#pullrequestreview-2942190988
PR Review Comment: https://git.openjdk.org/jdk/pull/25726#discussion_r2156530756
PR Review Comment: https://git.openjdk.org/jdk/pull/25726#discussion_r2156518028
More information about the hotspot-compiler-dev
mailing list