JDK-6960427 : deadlock on cold start of app with full permissions
  • Type: Bug
  • Component: deploy
  • Sub-Component: webstart
  • Affected Version: 6u20
  • Priority: P3
  • Status: Resolved
  • Resolution: Won't Fix
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2010-06-11
  • Updated: 2017-12-22
  • Resolved: 2017-12-22
Description
FULL PRODUCT VERSION :
java version "1.6.0_20"
Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]


EXTRA RELEVANT SYSTEM CONFIGURATION :
Java Console is set to show. JNLP application is not in cache. There are no stored security certificates.

A DESCRIPTION OF THE PROBLEM :
I have a Java application that requires all permissions. When starting for the first time with Java console enabled, a deadlock occurs involving the classloader and AWT locks. This is a simplified version of the JNLP:

<jnlp spec="6.0+" href="http://..." codebase="http://...">

    <information>
    ...
        <update check="always" policy="always"/>
    </information>

    <security>
        <all-permissions/>
    </security>
    
    <resources>
        <java version="1.6+"/>
        <jar href="customprogress.jar" version="1.0" download="progress" />
                
        <jar href="lazy1.jar"  download='lazy'/>
        <jar href="lazy2.jar"  download='lazy'/>
        ...
        <jar href="non-lazy1.jar" />
        <jar href="non-lazy2.jar" />
        ....

        <property .../>
    </resources>
    <application-desc main-class="my.MainClass" progress-class="my.NoOpProgress"/>
</jnlp>


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1 - enable Java console to show (not sure if it is on by default)

2 - launch application, it freezes right away. To be completely honest, I am skipping javaws and running straight from the javaws.jar and deploy.jar:

java
    -Xbootclasspath/a:/home/user/jdk1.6.0_20/jre/lib/deploy.jar
    -Xbootclasspath/a:/home/user/jdk1.6.0_20/jre/lib/javaws.jar
    -Ddeployment.javapi.cache.enabled=true
    com.sun.javaws.Main
    -Xnosplash
    http://myserver/myapp.jnlp

ACTUAL -
Found one Java-level deadlock:
=============================
"Thread-2":
  waiting to lock monitor 0x170fe894 (object 0x07f4f580, a java.awt.Component$AW
TTreeLock),
  which is held by "AWT-EventQueue-1"
"AWT-EventQueue-1":
  waiting to lock monitor 0x17194eec (object 0x07f43c50, a com.sun.jnlp.JNLPClas
sLoader),
  which is held by "Thread-2"

Java stack information for the threads listed above:
===================================================
"Thread-2":
        at java.awt.Container.addImpl(Unknown Source)
        - waiting to lock <0x07f4f580> (a java.awt.Component$AWTTreeLock)
        at java.awt.Container.add(Unknown Source)
        at com.sun.deploy.ui.DialogTemplate.createTopPanel(Unknown Source)
        at com.sun.deploy.ui.DialogTemplate.setSecurityContent(Unknown Source)
        at com.sun.deploy.ui.UIFactory$1.execute(Unknown Source)
        at com.sun.javaws.ui.JavawsSysRun.delegate(Unknown Source)
        at com.sun.deploy.util.DeploySysRun.execute(Unknown Source)
        at com.sun.deploy.util.DeploySysRun$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.deploy.util.DeploySysRun.executePrivileged(Unknown Source)
        at com.sun.deploy.ui.UIFactory.showSecurityDialog(Unknown Source)
        at com.sun.deploy.security.TrustDeciderDialog.showDialog(Unknown Source)

        at com.sun.deploy.security.X509Util.showSecurityDialog(Unknown Source)
        at com.sun.deploy.security.TrustDecider.isAllPermissionGranted(Unknown S
ource)
        at com.sun.javaws.security.AppPolicy.grantUnrestrictedAccess(Unknown Sou
rce)
        at com.sun.javaws.security.AppPolicy.addPermissions(Unknown Source)
        at com.sun.jnlp.JNLPClassLoader.getTrustedCodeSources(Unknown Source)
        at com.sun.deploy.security.CPCallbackHandler$ParentCallback.strategy(Unk
nown Source)
        at com.sun.deploy.security.CPCallbackHandler$ParentCallback.openClassPat
hElement(Unknown Source)
        - locked <0x07f851a8> (a com.sun.deploy.security.CPCallbackHandler$Paren
tCallback)
        at com.sun.deploy.security.DeployURLClassPath$JarLoader.getJarFile(Unkno
wn Source)
        at com.sun.deploy.security.DeployURLClassPath$JarLoader.access$700(Unkno
wn Source)
        at com.sun.deploy.security.DeployURLClassPath$JarLoader$1.run(Unknown So
urce)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.deploy.security.DeployURLClassPath$JarLoader.ensureOpen(Unkno
wn Source)
        at com.sun.deploy.security.DeployURLClassPath$JarLoader.<init>(Unknown S
ource)
        at com.sun.deploy.security.DeployURLClassPath$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source)
        at com.sun.deploy.security.DeployURLClassPath.getLoader(Unknown Source)
        - locked <0x07f59db0> (a com.sun.deploy.security.DeployURLClassPath)
        at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source
)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        - locked <0x07f438d0> (a com.sun.jnlp.JNLPClassLoader)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        - locked <0x07f43c50> (a com.sun.jnlp.JNLPClassLoader)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at com.sun.javaws.Launcher$2.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
"AWT-EventQueue-1":
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at sun.awt.FontConfiguration$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.awt.FontConfiguration.getFontCharsetEncoder(Unknown Source)
        at sun.awt.FontConfiguration.buildFontDescriptors(Unknown Source)
        at sun.awt.FontConfiguration.getFontDescriptors(Unknown Source)
        at sun.awt.FontConfiguration.getFontDescriptors(Unknown Source)
        at sun.awt.PlatformFont.<init>(Unknown Source)
        at sun.awt.windows.WFontPeer.<init>(Unknown Source)
        at sun.awt.windows.WToolkit.getFontPeer(Unknown Source)
        at java.awt.Font.getPeer_NoClientCode(Unknown Source)
        at java.awt.Font.getPeer(Unknown Source)
        at sun.awt.windows.WComponentPeer._setFont(Native Method)
        - locked <0x02e00038> (a sun.awt.windows.WFramePeer)
        at sun.awt.windows.WComponentPeer.setFont(Unknown Source)
        - locked <0x02e00038> (a sun.awt.windows.WFramePeer)
        at sun.awt.windows.WWindowPeer.initialize(Unknown Source)
        at sun.awt.windows.WFramePeer.initialize(Unknown Source)
        at sun.awt.windows.WComponentPeer.<init>(Unknown Source)
        at sun.awt.windows.WCanvasPeer.<init>(Unknown Source)
        at sun.awt.windows.WPanelPeer.<init>(Unknown Source)
        at sun.awt.windows.WWindowPeer.<init>(Unknown Source)
        at sun.awt.windows.WFramePeer.<init>(Unknown Source)
        at sun.awt.windows.WToolkit.createFrame(Unknown Source)
        at java.awt.Frame.addNotify(Unknown Source)
        - locked <0x07f4f580> (a java.awt.Component$AWTTreeLock)
        at java.awt.Window.show(Unknown Source)
        at java.awt.Component.show(Unknown Source)
        at java.awt.Component.setVisible(Unknown Source)
        at java.awt.Window.setVisible(Unknown Source)
        at com.sun.deploy.util.ConsoleWindow.showConsole(Unknown Source)
Pause reading child output to share cycles.
        at com.sun.javaws.util.JavawsConsoleController.showConsoleIfEnable(Unkno
wn Source)
        at com.sun.javaws.Launcher$1.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)

Found 1 deadlock.

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Ensure the Java console is disabled before trying to start the application.