JDK-8251397 : NPE on ClassValue.ClassValueMap.cacheArray
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 8,11,15,16
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-08-11
  • Updated: 2022-01-05
  • Resolved: 2020-09-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 15 JDK 16 JDK 8 Other
11.0.10Fixed 15.0.2Fixed 16 b17Fixed 8u291Fixed openjdk8u292Fixed
Description
When GraalVM is building its points-to analysis graph using jdk11u-dev, we see the JVM process fail with the following NPE:

Caused by: java.lang.NullPointerException
        at java.base/java.lang.ClassValue$ClassValueMap.loadFromCache(ClassValue.java:535)
        at java.base/java.lang.ClassValue$ClassValueMap.probeHomeLocation(ClassValue.java:541)
        at java.base/java.lang.ClassValue.get(ClassValue.java:101)
        at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIMetaAccessContext.fromClass(HotSpotJVMCIMetaAccessContext.java:163)
        at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.fromClass(HotSpotJVMCIRuntime.java:339)
        at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromObjectClass(HotSpotResolvedObjectTypeImpl.java:83)
        at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl.fromMetaspace(HotSpotResolvedObjectTypeImpl.java:97)
        at jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVM.resolveTypeInPool(Native Method)
        at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotConstantPool.loadReferencedType(HotSpotConstantPool.java:727)
        at java.base/jdk.internal.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)

The issue is with ClassValue.ClassValueMap.cacheArray field, which can sometimes be seen as null.

A discussion was started in core-lib-devs (see https://mail.openjdk.java.net/pipermail/core-libs-dev/2020-August/068086.html ) which confirmed the possibility of such issue and ideas were provided for potential fixes.

As a side note: an Oracle GraalVM distribution uses a special Oracle Labs JDK as base that has a more modern JVMCI stack compared to JDK 11, hence this issue is unlikely to be seen in that environment.

A fix will be sent for RFR shortly.
Comments
Fix Request (8u) Same reason as for 11u and 15u. Patch does not apply cleanly to 8u. 8u RFR (acked by Severin): https://mail.openjdk.java.net/pipermail/jdk8u-dev/2020-December/013178.html
07-12-2020

Got it - sorry for the noise.
10-11-2020

As far as I can tell, this problem exists in JDK 8 as well and the fix should be applied there as well.
10-11-2020

Yes, it affects JDK 8 as well, that is why "Affects Version: 8" is set :)
10-11-2020

Fix Request (15u) This fixes the concurrency bug and matches the codebases in 16 and 11u. Patch applies cleanly to 15u, passes tier{1,2}.
27-10-2020

Fix Request Backporting this patch eliminates the NPE found in Java 11. Patch applies cleanly to 11u. Tier1 tests pass with the patch.
02-10-2020

Changeset: 81e2cf82 Author: Galder ZamarrenĖƒo <galder@redhat.com> Committer: Severin Gehwolf <sgehwolf@openjdk.org> Date: 2020-09-17 13:42:15 +0000 URL: https://git.openjdk.java.net/jdk/commit/81e2cf82
17-09-2020

Assigned this issue to myself on behalf of Galder Zamarreno who is working on a fix.
11-08-2020