RFR: 8365656: [ubsan] G1CSetCandidateGroup::liveness() reports division by 0
Ivan Walulya
iwalulya at openjdk.org
Thu Aug 21 17:10:55 UTC 2025
On Thu, 21 Aug 2025 16:13:10 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:
> Hi all,
>
> please review this change that fixes a div-by-zero in calculating liveness for logging.
>
> It is possible that the young gen group cardset is empty when the `Cleanup` pause starts, making the liveness calculation divide by zero.
>
> The change special-cases this case when printing - I decided to always print the group in this case, regardless of length, just fudging the output value a bit. An alternative would be not printing it at all in this case. Feel free to argue for that solution. Also the printed value for liveness (0.0%) is up for discussion.
>
> Testing: failing test case does not fail any more now and then, gha
>
> Thanks,
> Thomas
Changes requested by iwalulya (Reviewer).
src/hotspot/share/gc/g1/g1ConcurrentMark.cpp line 3125:
> 3123: group->length(),
> 3124: group->gc_efficiency(),
> 3125: group->length() > 0 ? group->liveness_percent() : 0.0f,
Why not move this logic into `liveness_percent()` (i.e returns 0.0f if length() == 0)?
-------------
PR Review: https://git.openjdk.org/jdk/pull/26888#pullrequestreview-3141593342
PR Review Comment: https://git.openjdk.org/jdk/pull/26888#discussion_r2291667171
More information about the hotspot-gc-dev
mailing list