RFR: 8337981: ShenandoahHeap::is_in should check for alive regions [v4]

Aleksey Shipilev shade at openjdk.org
Mon Aug 19 11:20:06 UTC 2024


> The expected behavior of `CollectedHeap::is_in` is to check whether the object belongs to the committed parts of the heap:
> https://github.com/openjdk/jdk/blob/d19ba81ce12a99de1114c1bfe67392f5aee2104e/src/hotspot/share/gc/shared/collectedHeap.hpp#L273-L276
> 
> This is useful to check if object resides in the parts of the heap the GC knows are not dead. Yet, Shenandoah's check just verifies that oop is within the heap bounds. So `is_in` check for an object that is in trashed/empty region would pass by accident, and we will miss detecting bugs. This should be rectified. I believe "committed" is too weak for the test as well, since we really want to know if we can touch the object, i.e. if it is in active region.
> 
> I re-wired assertions/verification code to be clear whether we check for heap bounds or actual in-heap conditions.
> 
> Deeper testing revealed that reference processing code potentially loads a dead referent, but only to null-check it, or ask bitmap about it. Still, more precise `in_heap` check fails asserts in `CompressedOops::decode`. That required a bit of touchup as well.
> 
> Additional testing:
>  - [x] Linux AArch64 server fastdebug, `all` with `-XX:+UseShenandoahGC`
>  - [x] Linux AArch64 server fastdebug, `all` with `-XX:+UseShenandoahGC -XX:+ShenandoahVerify`

Aleksey Shipilev has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision:

 - Review feedback
 - Merge branch 'master' into JDK-8337981-shenandoah-is-in
 - Merge branch 'master' into JDK-8337981-shenandoah-is-in
 - Even stronger is_in check
 - Use is_in_reserved
 - Drop raw_referent to HeapWord*
 - Add some overrides
 - Merge branch 'master' into JDK-8337981-shenandoah-is-in
 - Style touchups
 - Fixing ShenandoahReferenceProcessor
 - ... and 2 more: https://git.openjdk.org/jdk/compare/ed2af769...2da163d1

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/20492/files
  - new: https://git.openjdk.org/jdk/pull/20492/files/0a0859a4..2da163d1

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=20492&range=03
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=20492&range=02-03

  Stats: 11187 lines in 265 files changed: 7236 ins; 2667 del; 1284 mod
  Patch: https://git.openjdk.org/jdk/pull/20492.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20492/head:pull/20492

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


More information about the hotspot-gc-dev mailing list