RFR: 8346888: [ubsan] block.cpp:1617:30: runtime error: 9.97582e+36 is outside the range of representable values of type 'int'
Matthias Baesken
mbaesken at openjdk.org
Tue Mar 11 08:15:54 UTC 2025
On Tue, 11 Mar 2025 08:11:19 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:
>> src/hotspot/share/opto/block.cpp line 1617:
>>
>>> 1615: float f_from_pct = (100 * freq) / b->_freq;
>>> 1616: float f_to_pct = (100 * freq) / target->_freq;
>>> 1617: int from_pct = (f_from_pct < (float)INT_MAX) ? (int)f_from_pct : INT_MAX;
>>
>> I think (float)INT_MAX is problematic. Due to rounding, isn't the result actually greater than INT_MAX?
>> Does it even make sense to have a "pct" that is greater than 100 here?
>> Do we want `int from_pct = MIN2((double)INT_MAX, (double)f_from_pct);` or maybe
>> `int from_pct = MIN2((100.0, (double)f_from_pct);`?
>
> Hi Dean, I added the (float) cast because AIX failed to compile the file without it , for the other platforms/compilers it was okay without the cast.
> Does it even make sense to have a "pct" that is greater than 100 here
I am not so familiar with the ranges that make sense for the from_pct. Maybe some C2 compiler expert could comment?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23962#discussion_r1988651183
More information about the hotspot-compiler-dev
mailing list