RFR: 8353468: [ubsan] arguments.cpp:2422:23: runtime error: 2.14748e+11 is outside the range of representable values of type 'int' [v6]
Stefan Karlsson
stefank at openjdk.org
Thu Sep 4 13:34:51 UTC 2025
On Wed, 3 Sep 2025 08:08:52 GMT, Afshin Zafari <azafari at openjdk.org> wrote:
>> In converting values of `-XMinf` and `-XMaxf` options to `int`, overflow was not checked.
>> The values are checked against INT_MAX and clamped.
>>
>> Tests: tiers 1-5.
>
> Afshin Zafari has updated the pull request incrementally with one additional commit since the last revision:
>
> message fix
I still find it weird that the error message says "percentage":
jio_fprintf(defaultStream::error_stream(),
"Bad max heap free percentage size: %s\n",
option->optionString);
The new code also mixes the style w.r.t. using redundant `else`s vs early returns. Could you straighten up the code so that all error checking is at the same indentation level?:
if (*err != '\0' || *tail == '\0') {
jio_fprintf(defaultStream::error_stream(),
"Bad max heap free ratio: %s\n",
option->optionString);
return JNI_EINVAL;
}
if (dmaxf < 0.0 || dmaxf > 1.0) {
jio_fprintf(defaultStream::error_stream(),
"-Xmaxf value (%s) is outside the allowed range [ 0.0 ... 1.0 ]\n",
option->optionString);
return JNI_EINVAL;
}
if (MinHeapFreeRatio > (uintx)(dmaxf * 100)) {
jio_fprintf(defaultStream::error_stream(),
"-Xmaxf value (%s) must be greater than or equal to the implicit -Xminf value (%3.2lf)\n",
tail, MinHeapFreeRatio / 100.0);
return JNI_EINVAL;
}
if (FLAG_SET_CMDLINE(MaxHeapFreeRatio, (uintx)(dmaxf * 100)) != JVMFlag::SUCCESS) {
return JNI_EINVAL;
}
This could be extracted into a local constant:
(uintx)(dmaxf * 100)
I don't think there should be a 3 here:
(%3.2lf)
In another PR I saw that the usage of `%lf` instead of `%f` was questioned. Should we be using `%lf` here?
if (FLAG_SET_CMDLINE(MaxHeapFreeRatio, (uintx)(dmaxf * 100)) != JVMFlag::SUCCESS) {
return JNI_EINVAL;
}
There's an incorrect indentation at the return statement.
-------------
Changes requested by stefank (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/26859#pullrequestreview-3185325686
More information about the hotspot-runtime-dev
mailing list