RFR: 8353468: [ubsan] arguments.cpp:2422:23: runtime error: 2.14748e+11 is outside the range of representable values of type 'int'
Stefan Karlsson
stefank at openjdk.org
Thu Aug 21 07:48:54 UTC 2025
On Wed, 20 Aug 2025 12:12:01 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.
The failing TestHeapFreeRatio.java test tests with an extreme positive value (2147483647), but it doesn't test with an extreme negative value:
public static void main(String args[]) throws Exception {
testMinMaxFreeRatio( "0.1", "0.5", Validation.VALID);
testMinMaxFreeRatio( ".1", ".5", Validation.VALID);
testMinMaxFreeRatio( "0.5", "0.5", Validation.VALID);
testMinMaxFreeRatio("=0.1", "0.5", Validation.MIN_INVALID);
testMinMaxFreeRatio("0.1f", "0.5", Validation.MIN_INVALID);
testMinMaxFreeRatio(
"INVALID", "0.5", Validation.MIN_INVALID);
testMinMaxFreeRatio( "0.1", "0.5f", Validation.MAX_INVALID);
testMinMaxFreeRatio( "0.1", "=0.5", Validation.MAX_INVALID);
testMinMaxFreeRatio(
"0.1", "INVALID", Validation.MAX_INVALID);
testMinMaxFreeRatio("-0.1", "0.5", Validation.OUT_OF_RANGE);
testMinMaxFreeRatio( "1.1", "0.5", Validation.OUT_OF_RANGE);
testMinMaxFreeRatio(
"2147483647", "0.5", Validation.OUT_OF_RANGE);
testMinMaxFreeRatio( "0.1", "-0.5", Validation.OUT_OF_RANGE);
testMinMaxFreeRatio( "0.1", "1.5", Validation.OUT_OF_RANGE);
testMinMaxFreeRatio(
"0.1", "2147483647", Validation.OUT_OF_RANGE);
testMinMaxFreeRatio( "0.5", "0.1", Validation.COMBINATION_INVALID);
testMinMaxFreeRatio( ".5", ".10", Validation.COMBINATION_INVALID);
testMinMaxFreeRatio("0.12","0.100", Validation.COMBINATION_INVALID);
}
Would ubsan hit a similar value if it did and would you have to guard against INT_MIN as well?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/26859#issuecomment-3209395616
More information about the hotspot-runtime-dev
mailing list