RFR: 8365656: [ubsan] G1CSetCandidateGroup::liveness() reports division by 0 [v2]

Francesco Andreuzzi duke at openjdk.org
Fri Aug 22 09:09:58 UTC 2025


On Fri, 22 Aug 2025 05:49:07 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 (has no regions assigned to it as no eden region has retired yet) 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, tier1-4
>> 
>> Thanks,
>>   Thomas
>
> Thomas Schatzl has updated the pull request incrementally with one additional commit since the last revision:
> 
>   * walulyai review

src/hotspot/share/gc/g1/g1ConcurrentMark.cpp line 3165:

> 3163:   G1CollectedHeap* g1h = G1CollectedHeap::heap();
> 3164: 
> 3165:   if (g1h->young_regions_cset_group()->length() != 0) {

Would it make sense to have this check inside `log_cset_candidate_group_add_total` instead?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26888#discussion_r2293160889


More information about the hotspot-gc-dev mailing list