RFR: 8367413: Fix potential truncation error in Arguments::set_heap_size() [v8]
Joel Sikström
jsikstro at openjdk.org
Wed Oct 8 13:31:25 UTC 2025
> Hello,
>
> There are several integer types used when setting the heap size ergonomically in `Arguments::set_heap_size()`, such as julong, uint64_t and size_t. It's not clear if this code works as intended on a 32-bit VM with more than 4GB physical memory. There might be issues when converting to/from size_t and uint64_t that we don't handle properly. I suggest we should be more robust and have more control over transitions between potentially smaller types.
>
> Additionally, I've gone ahead and added comments which I think makes it easier to understand what's going on in this function. I've tried my best to leave the existing behavior unchanged, apart from type conversion.
>
> Testing:
> * Oracle's tier1-8 on all Oracle supported platforms
Joel Sikström has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 12 commits:
- Merge branch 'master' into JDK-8367413_arguments_sizet_julong
- Rename limit_by_size_t_max to clamp_by_size_t_max
- Make limit_by_size_t_max to a static function in arguments.cpp
- Rename ram_limit_set to has_ram_limit
- Revert MaxRAM default removals, defer to future enhancement
- Namings and comment
- 8367413: Refactor types in Arguments::set_heap_size()
- Merge branch 'master' into JDK-8367413_arguments_sizet_julong
- Revert "8367413: Use size_t instead of julong in runtime/arguments.cpp"
This reverts commit 35c6057a4b5f0e478f3e703f6fa14b137cd73ca8.
- Revert "size_t casts for 32-bit part of test_arguments.cpp"
This reverts commit dba2ab4699b9295ba406abf174a7829600ce8625.
- ... and 2 more: https://git.openjdk.org/jdk/compare/23fcbb0b...f5649cb7
-------------
Changes: https://git.openjdk.org/jdk/pull/27224/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27224&range=07
Stats: 73 lines in 1 file changed: 18 ins; 6 del; 49 mod
Patch: https://git.openjdk.org/jdk/pull/27224.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/27224/head:pull/27224
PR: https://git.openjdk.org/jdk/pull/27224
More information about the hotspot-dev
mailing list