Integrated: 8339579: ZGC: Race results in only one of two remembered sets being cleared

Joel Sikström duke at openjdk.org
Thu Sep 5 13:42:53 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.
> 
> Tested with tier5, where the fails/crashes occured before this fix, and a reproducer of the crash as well.

This pull request has now been integrated.

Changeset: ab656c3a
Author:    Joel Sikström <joel.sikstrom at oracle.com>
Committer: Stefan Karlsson <stefank at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/ab656c3aab8157ed8e70bc126881cbadc825de93
Stats:     2 lines in 1 file changed: 0 ins; 0 del; 2 mod

8339579: ZGC: Race results in only one of two remembered sets being cleared

Reviewed-by: stefank, sjohanss

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

PR: https://git.openjdk.org/jdk/pull/20869


More information about the hotspot-gc-dev mailing list