JDK-8262762 : Deadlock in java.util.jar.JarFile
  • Type: Bug
  • Component: security-libs
  • Sub-Component: java.security
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • Submitted: 2021-03-01
  • Updated: 2022-05-03
  • Resolved: 2022-05-03
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
A deadlock condition may occur when a main thread is attempting to verify a Jar signature and another thread, that might be started by certain JVM tools, has locked LocaleDataMetaInfo by using ServiceLoader and also expects to lock JarFile, which the main thread is already holding


The following test reproduces the main thread conditions: 
java/security/Policy/SignedJar/SignedJarTest.java
sun/security/tools/jarsigner/multiRelease/MVJarSigningTest.java

Comments
Thanks Weijun! Unfortunately, for some reason, I am unable to view JDK-8275904. Is that scheduled for any upcoming 11u update release and is it assigned already? We'll look at the backport of the fix in JDK-8269039 to 11u as well and report back here on our findings (since the other ticket isn't accessible to us).
23-11-2021

As Sean commented above: "DisabledAlgorithmConstraints no longer calls SimpleDateFormat (the code was changed in JDK-8269039) so this particular issue is probably not an issue anymore". The backport to jdk11u at JDK-8275904 is still open. Let's see if it will fix the issue.
20-11-2021

I am reopening the ticket for further investigation, in light of the above. Please see the comment below for further details: ========================================================================== Steps to reproduce the issue ====================== Build: bash configure; make images; make-test-image ==== Test: make run-test-only TEST="test/jdk/java/security/Policy/SignedJar/SignedJarTest.java" JTREG="VM_OPTIONS= -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler" ==== JDK and environment: ================== JDK major version: 11.0.12 or 11.0.13 OS: macOS 10.15 Catalina, macOS 11 Big Sur, CentOS 7 Architecture: Intel Core i9 (amd64 Graal target) This problem was first reported here with the full stack trace: https://github.com/oracle/graal/issues/3831 but was subsequently closed as the issue is not in Graal. We also note that this patch https://cr.openjdk.java.net/~sgehwolf/webrevs/JDK-8196415/01/webrev/openjdk-11-dev.patch has not been applied to the JDK11 update releases yet. If it were to be applied then we would run into the same deadlock issue even without the java.security file for this test. ==========================================================================
20-11-2021

Hi Sean, Weijun, Thanks for taking a look at this. My colleagues Uma Srinivasan and Nik Vangerov have investigated this further, and we believe this is still an issue with at least OpenJDK 11. Here is the feedback from their investigation: ========================================================================== The OpenJDK test java/security/Policy/SignedJar/SignedJarTest.java fails with OpenJDK 11.0.12 or 11.0.13, with JVMCI enabled. The relevant portion from the stack trace of the hanging test given below shows that the issue is the same as reported in this ticket. Found one Java-level deadlock: ======================= "main": waiting to lock monitor 0x00007fb191aefd00 (object 0x00000007e01b8a00, a java.lang.Class), which is held by "JVMCI CompilerThread0" "JVMCI CompilerThread0": waiting to lock monitor 0x00007fb191aeff00 (object 0x00000007e01c1000, a java.util.jar.JarFile), which is held by "main" Further investigation reveals that the test started hanging after the modification to the SignedJarTest by this commit: 561041568e9effb5fc71c3539ead56f7a51e2b9b (https://hg.openjdk.java.net/jdk-updates/jdk11u-dev/rev/09590024353b). In particular, the `denyAfter 2019-01-01` clause introduced in the java.security file for this test causes the test to hang. If this clause is removed, the test passes. Further details are provided in the following comment. ==========================================================================
20-11-2021

DisabledAlgorithmConstraints no longer calls SimpleDateFormat (the code was changed in JDK-8269039) so this particular issue is probably not an issue anymore. I think you can probably close it.
05-11-2021

Hi [~weijun] & [~lmesnik] , Can you describe what specific "JVM Tools" expose this deadlock issue? Thanks!
02-11-2021

[~lmesnik] In most cases the test does not run with the "certain JVM tools" and it's not worth disable it in a whole.
24-06-2021

[~weijun], [~fguallini] Shouldn't be these tests disabled to reduce noise?
24-06-2021