RFR: 8339579: ZGC: Race results in only one of two remembered sets being cleared
Joel Sikström
duke at openjdk.org
Thu Sep 5 12:23:17 UTC 2024
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.
-------------
Commit messages:
- 8339579: ZGC: Race results in only one of two remembered sets being cleared
Changes: https://git.openjdk.org/jdk/pull/20869/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20869&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8339579
Stats: 2 lines in 1 file changed: 0 ins; 0 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/20869.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20869/head:pull/20869
PR: https://git.openjdk.org/jdk/pull/20869
More information about the hotspot-gc-dev
mailing list