RFR: 8367485: os::physical_memory is broken in 32-bit JVMs when running on 64-bit OSes [v4]
Thomas Stuefe
stuefe at openjdk.org
Thu Sep 18 14:51:24 UTC 2025
On Thu, 18 Sep 2025 14:02:00 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: Addressed reviewer's comments
src/hotspot/share/gc/shared/gcInitLogger.cpp line 66:
> 64: void GCInitLogger::print_memory() {
> 65: uint64_t memory = os::physical_memory();
> 66: log_info_p(gc, init)("Memory: " PROPERFMT, PROPERFMTARGS(memory));
PROPERFMT uses %zu.
(If you change this, please keep PROPERFMT as it is. Just change this to raw uint64_t printing).
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27335#discussion_r2359623341
More information about the hotspot-runtime-dev
mailing list