RFR: 8351077: Shenandoah: Update comments in ShenandoahConcurrentGC::op_reset_after_collect

Y. Srinivas Ramakrishna ysr at openjdk.org
Tue Mar 4 00:12:53 UTC 2025


On Mon, 3 Mar 2025 21:16:32 GMT, Y. Srinivas Ramakrishna <ysr at openjdk.org> wrote:

>> This is a trivial PR to update the code comments in ShenandoahConcurrentGC::op_reset_after_collect.
>> 
>> After doing more test and analysis, we have a better understanding why reset bitmap of young gen after concurrent cycle may cause crash if there is pending old GC cycle to execute: When there is soft reference in old gen, but the referent is in young, reseting bitmap of young will cause wrong state of the soft reference, which may lead to expected cashes.
>
> src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp line 1235:
> 
>> 1233:     // Valid bitmap of young generation is needed by concurrent weak references phase of old GC cycle,
>> 1234:     // because it is possible that there is soft reference in old generation with the referent in young generation;
>> 1235:     // therefore mark bitmap of young generation can't be reset if there will be old GC after the concurrent GC cycle.
> 
> I don't understand the comment. If the soft reference in old gen points to its referent in the young gen, then the latter should be either reachable, or should have been cleared (depending on who discovered the soft reference & the soft reference clearing policy). If the former, the old gen card should be dirty.
> 
> May be I am confused about the change in comment, but this may be pointing to a bug in the reference processing code or the associated card-marking code.
> 
> Or I am not clearly understanding your comment in context.

Thanks @earthling-amzn for explaining the issue to me offline. Based on my current understanding of the issue from that explanation, I'd suggest rewording the comment as follows:

// If we are in the midst of an old gc bootstrap or an old marking, we want to leave the mark bit map of
// the young generation intact. In particular, reference processing in the old generation may potentially
// need the reachability of a young generation referent of a Reference object in the old generation.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23872#discussion_r1978405645


More information about the shenandoah-dev mailing list