RFR: 8353468: [ubsan] arguments.cpp:2422:23: runtime error: 2.14748e+11 is outside the range of representable values of type 'int' [v3]
Afshin Zafari
azafari at openjdk.org
Thu Aug 28 07:29:46 UTC 2025
On Thu, 28 Aug 2025 01:26:03 GMT, David Holmes <dholmes at openjdk.org> wrote:
>> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
>>
>> improved invalid detection and error messages
>
> src/hotspot/share/runtime/arguments.cpp line 2422:
>
>> 2420: } else {
>> 2421: if (dmaxf < 0.0 || dmaxf > 1.0) {
>> 2422: JVMFlag::printError(true,"uintx MaxHeapFreeRatio=%s is outside the allowed range [ 0.0 ... 1.0 ]\n", tail);
>
> This needs to refer to the allowed range for `-Xmaxf` as that is what the user supplied. The user does not know this is just used to internally set `MaxHeapFreeRatio`. If `-Xminf` and `-Xmaxf` were actually VM `-XX` flags then we would have defined the appropriate constraint function for them. We need to emulate that here. There should also be checks that minf <= maxf.
This is exactly the source of confusion. User is allowed to enter `double` values in range `[0.0, 1.0]`, but the value is multiplied by 100 and stored in a `uintx`.
Using hard-coded constants `MinHeapFreeRatio ` and `MaxHeapFreeRatio` in the error message is as expected by tests.
These two flags have already constraint functions as `MinHeapFreeRatioConstraintFunc` and `MaxHeapFreeRatioConstraintFunc` where minf <= maxf is checked.
Checking the user input to be in [0.0, 1.0] cannot be done in the constraint functions, since the original input is missed due to * 100 and casting to uintx.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26859#discussion_r2306476665
More information about the hotspot-runtime-dev
mailing list