RFR: 8352185: Shenandoah: Invalid logic for remembered set verification

Xiaolong Peng xpeng at openjdk.org
Wed Mar 19 00:19:09 UTC 2025


On Tue, 18 Mar 2025 23:50:24 GMT, Kelvin Nilsen <kdnilsen at openjdk.org> wrote:

>> There are some scenarios in which GenShen may have improper remembered set verification logic:
>> 
>> 1. Concurrent young cycles following a Full GC:
>> 
>> In the end of ShenandoahFullGC, it resets bitmaps for the entire heap w/o resetting marking context to be incomplete, but ShenandoahVerifier has code like below to get a complete old marking context for remembered set verification
>> 
>> 
>> ShenandoahVerifier  
>> ShenandoahMarkingContext* ShenandoahVerifier::get_marking_context_for_old() {
>>   shenandoah_assert_generations_reconciled();
>>   if (_heap->old_generation()->is_mark_complete() || _heap->gc_generation()->is_global()) {
>>     return _heap->complete_marking_context();
>>   }
>>   return nullptr;
>> }
>> 
>> 
>> For the concurrent young GC cycles after a full GC, the old marking context used for remembered set verification is stale, and may cause unexpected result. 
>> 
>> 2. For the impl of `ShenandoahVerifier::get_marking_context_for_old` mentioned above, it always return a marking context for global GC, but marking bitmaps is already reset before before init-mark, `ShenandoahVerifier::help_verify_region_rem_set` always skip verification in this case. 
>> 
>> 3. ShenandoahConcurrentGC always clean remembered set read table, but only swap read/write table when gc generation is young, this issue causes remembered set verification before init-mark to use a completely clean remembered set, but it is covered by issue 2. 
>> 
>> 
>> ### Test
>> - [x] `make test TEST=hotspot_gc_shenandoah`
>
> src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp line 660:
> 
>> 658: 
>> 659:     // Verify before mark is done before swapping card tables,
>> 660:     // therefore the write card table will be verified before being taken snapshot.
> 
> Not a big deal, but this is two sentences.  "... swapping card tables.  Therefore, the write card table is verified before we swap read and write card tables."

Thanks, I'll fix it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24092#discussion_r2002187325


More information about the hotspot-gc-dev mailing list