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

Anton Artemov duke at openjdk.org
Thu Sep 25 09:18:03 UTC 2025


On Thu, 25 Sep 2025 08:47:44 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 with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision:
> 
>  - Merge remote-tracking branch 'origin/master' into JDK-8367485-os-physical-memory-broken-32bit-on-64bit
>  - 8367485: Alignment of vars in os_windows.cpp
>  - 8367485: Indentation in GCInitLogger::print_memory()
>  - 8367485: Changed output format in GCInitLogger::print_memory()
>  - 8367485: Addressed reviewers' comments.
>  - 8367485: Indentation fix.
>  - 8367485: Addressed reviewer's comments.
>  - 8367485: Addressed reviewer's comments
>  - 8367485: Addressed reviewer's comments.
>  - 8367485: Refactoring with uint64_t
>  - ... and 2 more: https://git.openjdk.org/jdk/compare/45a162e9...b39817de

I added a typedef as suggested as an alias for `uint64_t`. Though with "_type" ending, which makes it somewhat long.

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

PR Comment: https://git.openjdk.org/jdk/pull/27335#issuecomment-3333028090


More information about the hotspot-dev mailing list