[jdk17] RFR: 8269897: Shenandoah: Treat UNKNOWN refs access as strong
Roman Kennke
rkennke at openjdk.java.net
Tue Jul 6 19:17:58 UTC 2021
We've observed test failures in jcstress, see:
https://bugs.openjdk.java.net/browse/JDK-8269897
We used to treat UNKNOWN reference accesses like weak accesses. UNKNOWN is used for Unsafe, reflection and JNI accesses, where it cannot be determined at compilation-time if we are accessing a regular field or a Reflection.referent field. The rationale for treating UNKNOWN as weak was that if the reference is a regular reference, then the value would be strongly reachable anyway, and only if it is a referent field would reachability matter. However, it turns out that this assumption is wrong: the test shows that a reference that is only weakly reachable can be legitimately written into a field, thus resurrecting the reference, and when that weakly reachable reference is loaded, it would be (wrongly) filtered as NULL.
A fix is to treat UNKNOWN accesses as strong. Accessing Reference.referent via reflection, JNI or Unsafe is Bad Idea anyway.
This test shows the problem with CAS, but I believe it affects all accesses via reflection, JNI, etc.
Testing:
- [x] the provided jcstress test
- [x] hotspot_gc_shenandoah
- [x] tier1
-------------
Commit messages:
- 8269897: Shenandoah: Treat UNKNOWN refs access as strong
Changes: https://git.openjdk.java.net/jdk17/pull/219/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk17&pr=219&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8269897
Stats: 3 lines in 2 files changed: 0 ins; 0 del; 3 mod
Patch: https://git.openjdk.java.net/jdk17/pull/219.diff
Fetch: git fetch https://git.openjdk.java.net/jdk17 pull/219/head:pull/219
PR: https://git.openjdk.java.net/jdk17/pull/219
More information about the shenandoah-dev
mailing list