RFR: 8364816: GetLastError() in os_windows.cpp should not store value to errno [v3]

Anton Artemov duke at openjdk.org
Wed Aug 27 10:51:57 UTC 2025


On Wed, 27 Aug 2025 08:42:50 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

>> Thanks for spotting. Actually, this comment, as well as the code around it, is mine as well. When writing it, I was storing results of `GetLastError()` in `errno`, which as we know is wrong and is addressed in this PR. 
>> 
>> The callers of `get_path_to_target()` do not expect any value in `errno` actually. The only thing they do when failing (this is where the `errno` value would be potentially useful) is that freeing some char array and returning -1. The error, which caused it, has been already reported. The comment is misleading. I fixed it.
>
> I think we still need to set errno in the failure path in https://github.com/toxaart/jdk/blob/JDK-8364816-get-last-error/src/hotspot/os/windows/os_windows.cpp#L4804-L4811.
> 
> Right next to the Windows specific code that you removed in this PR, we are checking the errno result, which is unset if we exit from the path calling `get_path_to_target()`. See https://github.com/toxaart/jdk/blob/JDK-8364816-get-last-error/src/hotspot/share/cds/aotClassLocation.cpp#L234-L246.

This is an extremely rare case when someone wants to use symbolic links and cds archives. I have addressed.

Tested in tiers 1 - 3, all green.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26901#discussion_r2303558867


More information about the hotspot-runtime-dev mailing list