> The test can run out of heap with -Xcheck:jni and ZGC. The cause is in the 
> checked IsSameObject, not in the test.
> 
> The checked wrapper validates its arguments by resolving them, and for a weak 
> global ref that keeps the referent alive while a GC is marking. The unchecked 
> IsSameObject has not done that since JDK 12. The HeapMonitor agent keeps a 
> weak global ref for every sampled object and compares them against null after 
> a GC. With -Xcheck:jni those compares kept the sampled objects alive.
> 
> Now the wrapper only checks that the handles are valid. It does not resolve 
> them. A bad handle gets the same fatal error as before.
> 
> Added TestCheckedIsSameObject. It compares a weak global ref against null in 
> both argument positions while a concurrent GC is marking, then checks the ref 
> is cleared when the GC is done.
> 
> The heap in HeapMonitorThreadTest is back to 512m. The gc logging stays in.
> 
> ---
> 
> Testing:
> - [x] The new test fails without the fix and passes with it. It ran with G1 
> and ZGC on linux-x64, linux-aarch64, macosx-aarch64 and windows-x64 debug 
> builds, and with -Xcomp and -Xint on linux-x64. HeapMonitorThreadTest with 
> -Xcheck:jni -XX:+UseZGC passed 500 of 500 runs on linux-x64, it failed 6 of 
> 500 without the fix. It also passed 50 runs on linux-aarch64 and 20 each on 
> macosx-aarch64 and windows-x64. serviceability/jvmti, runtime/jni, 
> runtime/SameObject, gc/TestJNIWeak and 
> runtime/valhalla/valuetypes/TestJNIIsSameObject.java passed with -Xcheck:jni 
> on linux-x64. tier1-3.
> 
> ---------
> - [x] I confirm that I make this contribution in accordance with the [OpenJDK 
> Interim AI Policy](https://openjdk.org/legal/ai).

Shiv Shah 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 six additional commits since the 
last revision:

 - Merge remote-tracking branch 'upstream/master' into JDK-8323421
 - check only the handles in checked IsSameObject, add a test, heap back to 512m
 - Merge remote-tracking branch 'upstream/master' into JDK-8323421
 - enable gc logging in the test
 - Remove bug tag and update copyright year
 - 8323421: 
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorThreadTest.java fails 
with OOME

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/32229/files
  - new: https://git.openjdk.org/jdk/pull/32229/files/208f926e..a42c0f80

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

  Stats: 729844 lines in 8455 files changed: 477945 ins; 171431 del; 80468 mod
  Patch: https://git.openjdk.org/jdk/pull/32229.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/32229/head:pull/32229

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

Reply via email to