RFR: 8353468: [ubsan] arguments.cpp:2422:23: runtime error: 2.14748e+11 is outside the range of representable values of type 'int'

David Holmes dholmes at openjdk.org
Wed Aug 27 06:55:43 UTC 2025


On Thu, 21 Aug 2025 07:46:29 GMT, Stefan Karlsson <stefank 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?

@stefank there is a bit of a history with the `-Xminf/-Xmaxf` flags and I agree there is more to clean up here ... maybe even get rid of these flags ... they are not even documented in the manpage when they should be!

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

PR Comment: https://git.openjdk.org/jdk/pull/26859#issuecomment-3226988421


More information about the hotspot-runtime-dev mailing list