Integrated: 8367413: Fix potential truncation error in Arguments::set_heap_size()

Joel Sikström jsikstro at openjdk.org
Thu Oct 9 08:21:03 UTC 2025


On Thu, 11 Sep 2025 12:39:18 GMT, Joel Sikström <jsikstro at openjdk.org> wrote:

> 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

This pull request has now been integrated.

Changeset: af2fbd5a
Author:    Joel Sikström <jsikstro at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/af2fbd5a7182cabdd88764b5653d2ce666f05d70
Stats:     73 lines in 1 file changed: 18 ins; 6 del; 49 mod

8367413: Fix potential truncation error in Arguments::set_heap_size()

Reviewed-by: ayang, lkorinth

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

PR: https://git.openjdk.org/jdk/pull/27224


More information about the hotspot-dev mailing list