RFR: Only verify last object start for marked objects [v2]

Kelvin Nilsen kdnilsen at openjdk.java.net
Mon Dec 6 19:53:54 UTC 2021


On Fri, 3 Dec 2021 21:53:07 GMT, William Kemper <wkemper at openjdk.org> wrote:

>> src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.inline.hpp line 402:
>> 
>>> 400:     max_offset = CardTable::card_size_in_words;
>>> 401:   }
>>> 402:   size_t prev_offset = offset;
>> 
>> Is this change motivated by a detected bug, or is this just a "style" improvement?  It looks to me like this change is equivalent to the original code, because in both cases (when !ctx and ctx), we unconditionally set prev_offset to offset in the first iteration of the do-while loop.
>
> Unconditionally setting prev_offset in the second branch (i.e., when `ctx` is not null) _is_ the bug. If the code there sets prev_offset to refer to refer to an _unmarked_ object, the following verification check to get the `size` on an unmarked object could crash. The intention here was to make sure that `prev_offset` never refers to an unmarked object, but this change isn't enough to guarantee that.

Thanks for clarifying.  Looks good to me as now drafted.

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

PR: https://git.openjdk.java.net/shenandoah/pull/103


More information about the shenandoah-dev mailing list