RFR: 8344414: ZGC: Another division by zero in rule_major_allocation_rate (ubsan)
Axel Boldt-Christmas
aboldtch at openjdk.org
Tue Nov 19 07:24:55 UTC 2024
This specific issue was known since #20888. As well as a more serious issue in `calculate_extra_young_gc_time` which may introduce a `NaN`. This specific issue is sane as long as we have IEEE 754 sans the C++ standard making division by zero UB.
As discussed in #21304 it is probably better to try and tackle the division by zero issue by making sure the input is never zero. This patch introduces a small offset to the average which will effectively leave the value unchanged unless it is zero, and behave as almost zero in calculations without causing actual division by zero.
There is still the issue with `NaN`, this patch adds a short circuit when this can occur and returns the analytical result of the calculation.
-------------
Commit messages:
- 8344414: ZGC: Another division by zero in rule_major_allocation_rate (ubsan)
Changes: https://git.openjdk.org/jdk/pull/22228/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22228&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8344414
Stats: 27 lines in 3 files changed: 10 ins; 1 del; 16 mod
Patch: https://git.openjdk.org/jdk/pull/22228.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/22228/head:pull/22228
PR: https://git.openjdk.org/jdk/pull/22228
More information about the hotspot-gc-dev
mailing list