RFR: 8274286: Skip null for make_referent_alive in referenceProcessor

Kim Barrett kbarrett at openjdk.java.net
Sat Sep 25 19:32:02 UTC 2021


On Fri, 24 Sep 2021 13:42:14 GMT, Albert Mingkun Yang <ayang at openjdk.org> wrote:

> Simple change of avoiding a virtual call for null referent. With this change, two methods of processing the discovered list, `process_discovered_list_work` and `preclean_discovered_reflist`, share the same structure.
> 
> Test: hotspot_gc

Changes requested by kbarrett (Reviewer).

src/hotspot/share/gc/shared/referenceProcessor.cpp line 267:

> 265: 
> 266: void DiscoveredListIterator::make_referent_alive() {
> 267:   assert(referent() != nullptr, "precondition");

This assert is not correct.  Preclean runs concurrently with the mutator.  The mutator could clear the reference between the time it is accessed by the list iterator and the call to make_referent_alive.  Looking at this also makes me wonder if the keep-alive function is safe against a racing clear by the mutator.

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

PR: https://git.openjdk.java.net/jdk/pull/5682



More information about the hotspot-gc-dev mailing list