[crac] RFR: Fix NPE on ZipFile$Source access [v2]

Anton Kozlov akozlov at openjdk.java.net
Fri Apr 8 19:14:10 UTC 2022


> A race between ZipFile$CleanableResource.run() and ZipFile$Resource.beforeCheckpoint() can lead to NullPointerException when zsrc == null. This is observed on some runs of JavaCompilerCRaC.java from #16. The change aligns beforeCheckpoint() with the run(), providing the zsrc check and the proper locking.
> 
> The exception looks like below:
> 
> java.lang.reflect.InvocationTargetException
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
> 	at java.base/jdk.internal.loader.URLClassPath$JarLoader$ClassLoaderJarFile.beforeCheckpoint(URLClassPath.java:837)
> 	at java.base/jdk.crac.impl.AbstractContextImpl.beforeCheckpoint(AbstractContextImpl.java:66)
> 	at java.base/jdk.crac.impl.AbstractContextImpl.beforeCheckpoint(AbstractContextImpl.java:66)
> 	at java.base/jdk.crac.Core.checkpointRestore1(Core.java:108)
> 	at java.base/jdk.crac.Core.checkpointRestore(Core.java:182)
> 	at JavaCompilerCRaC.main(JavaCompilerCRaC.java:27)
> Caused by: java.lang.NullPointerException: Cannot invoke "java.util.zip.ZipFile$Source.getFile()" because the return value of "java.util.zip.ZipFile$CleanableResource.getSource()" is null
> 	at java.base/java.util.zip.ZipFile.beforeCheckpoint(ZipFile.java:1088)
> 	... 10 more

Anton Kozlov has updated the pull request incrementally with two additional commits since the last revision:

 - Merge branch 'zip-fix' of https://github.com/AntonKozlov/crac into zip-fix
 - Fix NPE on ZipFile$Source access

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

Changes:
  - all: https://git.openjdk.java.net/crac/pull/17/files
  - new: https://git.openjdk.java.net/crac/pull/17/files/d1a74be6..8718c10a

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=crac&pr=17&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=crac&pr=17&range=00-01

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.java.net/crac/pull/17.diff
  Fetch: git fetch https://git.openjdk.java.net/crac pull/17/head:pull/17

PR: https://git.openjdk.java.net/crac/pull/17


More information about the crac-dev mailing list