RFR: 8365656: [ubsan] G1CSetCandidateGroup::liveness() reports division by 0 [v3]
Albert Mingkun Yang
ayang at openjdk.org
Fri Aug 22 11:09:11 UTC 2025
On Thu, 21 Aug 2025 17:07:26 GMT, Ivan Walulya <iwalulya at openjdk.org> wrote:
>> Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:
>>
>> * fandreuz review
>
> 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)?
I actually think the zero-length checking should be done at the caller -- it's meaningless to ask `liveness_percent` on a zero-length group. Looking at neighboring code, does `gc_efficiency` have a sensible meaning for a zero-length group? Callees should have non-zero-length as precondition.
Therefore, I suggest reorder the print a bit so that length-sensitive queries comes after `group->length()`, sth like:
type
group->card_set()->mem_size(),
group->length(),
group->length() > 0 ? group->gc_efficiency(), 0,
group->length() > 0 ? group->liveness_percent(), 0);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26888#discussion_r2293427961
More information about the hotspot-gc-dev
mailing list