RFR: 8255131: G1CollectedHeap::is_in() returns wrong result

Kim Barrett kbarrett at openjdk.java.net
Thu Oct 22 11:06:15 UTC 2020


On Thu, 22 Oct 2020 08:46:06 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

> Hi all,
> 
>   please review this change to exchange the broken G1CollectedHeap::is_in() by G1CollectedHeap::is_in_exact() that has the same performance profile and correct.
> 
> G1CollectedHeap::is_in() returns true for any region ever committed (and crashes for not yet committed regions), while is_in_exact() (almost) did the right thing. Almost because HeapRegionManager::is_available() would assert if the given pointer is outside the heap and it's not guarded by is_in_reserved.
> 
> Test: tier1
> 
> Thanks,
>   Thomas

Changes requested by kbarrett (Reviewer).

src/hotspot/share/gc/g1/g1CollectedHeap.cpp line 2264:

> 2262: bool G1CollectedHeap::is_in(const void* p) const {
> 2263:   if (is_in_reserved(p) &&
> 2264:     _hrm->is_available(addr_to_region((HeapWord*)p))) {

This line is misindented.  But rather than adjusting the indentation, how about instead changing the function to
bool G1CollectedHeap::is_in(const void* p) const {
  return is_in_reserved(p) && _hrm->is_available(addr_to_region((HeapWord*)p));
}

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

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



More information about the hotspot-gc-dev mailing list