RFR: 8366145: Help diagnose ubsan division by zero in computing pause time ratios

Thomas Schatzl tschatzl at openjdk.org
Wed Aug 27 14:10:42 UTC 2025


On Wed, 27 Aug 2025 10:03:53 GMT, Leo Korinth <lkorinth at openjdk.org> wrote:

>> src/hotspot/share/gc/g1/g1Analytics.cpp line 167:
>> 
>>> 165: 
>>> 166:   double short_interval_ms = (end_time_sec - most_recent_gc_end_time_sec()) * 1000.0;
>>> 167:   assert(fabs(short_interval_ms) != fabs(0.0), "short_interval_ms should not be zero, calculated from %f and %f", end_time_sec,  most_recent_gc_end_time_sec());
>> 
>> Not sure why one would need the `fabs(0.0)`. It simply returns `0.0`.
>> Suggestion:
>> 
>>   assert(fabs(short_interval_ms) != 0.0, "short_interval_ms should not be zero, calculated from %f and %f", end_time_sec,  most_recent_gc_end_time_sec());
>> 
>> Maybe even compare against some very small epsilon, which would also be suspicious given that pauses smaller than a nanosecond or so seem suspicious in any case.
>
> Do you want me to remove the right `fabs` or both `fabs`? I am not interested in an epsilon, I want to see when we get a real division by zero. The code clamps the big value after the computation.

just the one suggested in the Suggestion box is good enough.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26939#discussion_r2304054684


More information about the hotspot-gc-dev mailing list