RFR: 8367485: os::physical_memory is broken in 32-bit JVMs when running on 64-bit OSes [v8]

Joel Sikström jsikstro at openjdk.org
Fri Sep 19 07:53:41 UTC 2025


On Thu, 18 Sep 2025 15:15:23 GMT, Anton Artemov <duke at openjdk.org> wrote:

>> Hi, please consider the following changes:
>> 
>> In this PR we address the overflow issue in `os::physical_memory()` on Linux, which can occur when running a 32-bit JVM on a 64-bit machine, introduced by https://bugs.openjdk.org/browse/JDK-8357086. The problem is that the product of _SC_PHYS_PAGES and _SC_PAGESIZE can overflow according to the documentation. 
>> 
>> The issue is addressed by changing the output type of all related functions to `uint64_t`.
>> 
>> Tested in tiers 1 - 5.
>
> Anton Artemov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8367485: Indentation in GCInitLogger::print_memory()

Great work! I have a small suggestion below, otherwise I think this looks good.

src/hotspot/os/windows/os_windows.cpp line 3969:

> 3967: uint64_t os::win32::_physical_memory           = 0;
> 3968: 
> 3969: bool     os::win32::_is_windows_server         = false;

Continuing on Stefan's suggestion, we should also align them with the static variables below.

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

Marked as reviewed by jsikstro (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/27335#pullrequestreview-3243561494
PR Review Comment: https://git.openjdk.org/jdk/pull/27335#discussion_r2362038900


More information about the hotspot-runtime-dev mailing list