Integrated: 8339163: ZGC: Race in clearing of remembered sets

Joel Sikström duke at openjdk.org
Wed Sep 4 09:12:23 UTC 2024


On Mon, 2 Sep 2024 13:09:09 GMT, Joel Sikström <duke at openjdk.org> wrote:

> When a young collection is in the "concurrent mark" phase and is scanning remembered sets (remsets) to find roots into the young gen it "consumes" the remset when it is finished by clearing it (using memset).
> 
> At the same time, an old collection might find a completely empty/garbage page that it will insert into the page cache. Before inserting into the page cache, the page's remset is cleared (using memset).
> 
> These two operations might interfere, resulting in both threads clearing the memory simultaneously.
> 
> This race was found in connection to https://bugs.openjdk.org/browse/JDK-8339161 where I experimented replacing some clears of remsets with free's and got a crash on Windows from memset when operating on free'd memory.
> 
> This patch makes sure that remsets are only cleared in the "concurrent mark" phase if not already handled by an old collection.
> 
> Tested with tiers 1-3 and with a local test that crashes if both threads handle the remset.

This pull request has now been integrated.

Changeset: 7ad61605
Author:    Joel Sikström <joel.sikstrom at oracle.com>
Committer: Stefan Karlsson <stefank at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/7ad61605f1669f51a97f4f263a7afaa9ab7706be
Stats:     26 lines in 2 files changed: 14 ins; 9 del; 3 mod

8339163: ZGC: Race in clearing of remembered sets

Reviewed-by: stefank, eosterlund, aboldtch

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

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


More information about the hotspot-gc-dev mailing list