RFR: 8339579: ZGC: Race results in only one of two remembered sets being cleared
Stefan Karlsson
stefank at openjdk.org
Thu Sep 5 12:44:49 UTC 2024
On Thu, 5 Sep 2024 12:18:48 GMT, Joel Sikström <duke at openjdk.org> wrote:
> https://github.com/openjdk/jdk/pull/20821 introduced a fix that skips clearing of a potential remembered set in the young collection in favor of doing it only in the old collection.
>
> The code responsible for clearing the remset (`ZRememberedSet::clear_all()`) is dependent on the `_current` variable in ZRememberedSet not being altered in between the two "clear_*" calls in `ZRememberedSet::clear_all()`. If the remembered set is being cleared in the old collection, and successfully clears the current remset with `clear_current()`, a young collection might then flip/swap the current/previous remembered sets by changing the `_current` value in ZRememberedSet. This would mean that the call to clear_previous() would clean the same bitmap again, resulting in one of the two bitmaps not being cleared at all. This will later crash in an assert checking if both bitmaps are empty/clear when the page is being freed.
>
> Code in question:
> ```c++
> void ZRememberedSet::clear_all() {
> clear_current();
> clear_previous();
> }
>
>
> This PR makes sure that clearing is done independently of what the `_current` value is, by accessing the two bitmaps directly.
Looks good!
-------------
Marked as reviewed by stefank (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/20869#pullrequestreview-2282883401
More information about the hotspot-gc-dev
mailing list