JDK-6284332 : IE/Plugin hang when applets are repeatedly opened and closed
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 5.0u4
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-06-11
  • Updated: 2011-02-16
  • Resolved: 2006-05-05
Related Reports
Duplicate :  
Description
Customer's industrial automation application frequently opens new applets corresponding to various functions it performs. Once the applets are no longer needed, they get closed. Repeating opening/closing of applets causes the IE to hang. IE stops responding to any user actions (IE window cannot be even moved to a different location on the screen).

A stress test based on customer's application repeatedly opens/closes applets and hangs after 20-40 hours of running. The test performs the following sequence:

1. Login to the application
2. Open main applet window
3. Press a certain button which causes another child applet window to come up
4. Wait until child applet window loads and close it
5. goto step 3

The plugin java trace file is attached to this report. See the comments section for the native dump file.

The full native stack trace is attached. Native threads 32 and 34 look suspicious:

thread 34:

015de850 6d405117 0000632c ffffffff 075e2208 kernel32!WaitForSingleObject+0xf
015de860 6d40257e 00000000 00000000 075e2208 jpiexp32!CJavaFrame::~CJavaFrame+0x13
015de88c 6d40261b 00000000 00ff73d0 00000000 jpiexp32!CAxControl::Cleanup+0xa3
015de8b8 6d4074d6 075e2208 749551cf 075e2288 jpiexp32!CAxControl::IOleInPlaceObject_InPlaceDeactivate+0x30
015de8c0 749551cf 075e2288 00000002 00000000 jpiexp32!ATL::IOleInPlaceObjectWindowlessImpl<CAxControl>::InPlaceDeactivate+0x13

thread 32:

.........
087fea54 6d3e8856 02d81d68 075edfe0 075edfe0 jpicom32!CDispatchWrapper::invokeImpl+0x238
087fea90 6d402151 02d81d6c 075edfe0 00000001 jpicom32!CDispatchWrapper::Invoke+0x5e
087feacc 6d406731 00000435 00000000 075edfe0 jpiexp32!CAxControl::OnInvokeScript+0x23
087feaf4 6d40912a 000803ce 00000435 00000000 jpiexp32!CAxControl::ProcessWindowMessage+0x17c
087feb3c 77d43a68 05eeef1c 00000435 00000000 jpiexp32!ATL::CWindowImplBaseT<ATL::CWindow,ATL::CWinTraits<1442840576,0> >::WindowProc+0x4b

Thread 32 is in the process if destroying an embedded frame. Thread 34 is in the wait state possibly for a handle to be signalled when the IExplorerEmbeddedFrame processes the windowClosing
event. If the event never arrives (for exapmle when the appropriate EventQueue is already destroyed), this could be a native deadlock.

Java Stack trace at the hang point is as follows:

Full thread dump Java HotSpot(TM) Client VM (1.5.0_04-ea-b04 mixed mode, sharing
):

"TimerQueue" daemon prio=5 tid=0x075624b0 nid=0xf0c in Object.wait() [0x091ff000
..0x091ffbe8]
        at java.lang.Object.wait(Native Method)
        at javax.swing.TimerQueue.run(Unknown Source)
        - locked <0x22680558> (a javax.swing.TimerQueue)
        at java.lang.Thread.run(Unknown Source)

"Thread-23719" prio=7 tid=0x05eec3a8 nid=0xb48 runnable [0x02f9f000..0x02f9fce8]

        at java.net.PlainSocketImpl.socketAccept(Native Method)
        at java.net.PlainSocketImpl.accept(Unknown Source)
        - locked <0x22680638> (a java.net.SocksSocketImpl)
        at java.net.ServerSocket.implAccept(Unknown Source)
        at java.net.ServerSocket.accept(Unknown Source)
        at com.sun.deploy.si.SingleInstanceImpl$SingleInstanceServer$2.run(Unkno
wn Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.deploy.si.SingleInstanceImpl$SingleInstanceServer.run(Unknown
 Source)

"Thread-23718" prio=5 tid=0x075d7e18 nid=0xcf0 in Object.wait() [0x06a9f000..0x0
6a9f7f4]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x22680758> (a java.awt.EventQueue$1AWTInvocationLock)
        at java.lang.Object.wait(Unknown Source)
        at java.awt.EventQueue.invokeAndWait(Unknown Source)
        - locked <0x22680758> (a java.awt.EventQueue$1AWTInvocationLock)
        at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
        at com.sun.deploy.util.DialogFactory.showAboutJavaDialog(Unknown Source)


"Thread-23704" prio=5 tid=0x076ed488 nid=0xd38 runnable [0x00000000..0x015de81c]


"STARDOM VDS HMI Graphic Engine Applet [ Button_001 ]" prio=4 tid=0x05ed43e8 nid
=0xe7c in Object.wait() [0x0eecf000..0x0eecfae8]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x23aa1bb8> (a sun.plugin.AppletViewer)
        at java.lang.Object.wait(Unknown Source)
        at sun.applet.AppletPanel.getNextEvent(Unknown Source)
        - locked <0x23aa1bb8> (a sun.plugin.AppletViewer)
        at sun.applet.AppletPanel.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

"Thread-32" prio=5 tid=0x05f234c0 nid=0xe8c runnable [0x00000000..0x087fe8a0]

"Direct Clip" daemon prio=7 tid=0x05f93008 nid=0xd08 in Object.wait() [0x0e4cf00
0..0x0e4cfc68]
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Unknown Source)
        at com.sun.media.sound.DirectAudioDevice$DirectClip.run(Unknown Source)
        - locked <0x234e8310> (a java.lang.Object)
        at java.lang.Thread.run(Unknown Source)

"Java Sound Event Dispatcher" daemon prio=4 tid=0x05ff6c08 nid=0x62c waiting on
condition [0x08eff000..0x08effb68]
        at java.lang.Thread.sleep(Native Method)
        at com.sun.media.sound.DirectAudioDevice$DirectDL.implClose(Unknown Sour
ce)
        at com.sun.media.sound.DirectAudioDevice$DirectClip.implClose(Unknown So
urce)
        at com.sun.media.sound.AbstractDataLine.close(Unknown Source)
        - locked <0x234e7058> (a com.sun.media.sound.DirectAudioDevice)
        at com.sun.media.sound.EventDispatcher.closeAutoClosingClips(Unknown Sou
rce)
        - locked <0x22ee32d8> (a java.util.ArrayList)
        at com.sun.media.sound.EventDispatcher.dispatchEvents(Unknown Source)
        at com.sun.media.sound.EventDispatcher.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

"Thread-16" prio=5 tid=0x05f16aa8 nid=0xe24 runnable [0x00000000..0x086fe670]

"AWT-EventQueue-4" prio=4 tid=0x0762fab0 nid=0xff0 waiting for monitor entry [0x
085ff000..0x085ffb68]
        at java.awt.Component.getGraphicsConfiguration(Unknown Source)
        - waiting to lock <0x227b6a38> (a java.awt.Component$AWTTreeLock)
        at javax.swing.RepaintManager.getVolatileOffscreenBuffer(Unknown Source)

        at javax.swing.JComponent.paintDoubleBuffered(Unknown Source)
        at javax.swing.JComponent.paint(Unknown Source)
        at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source)
        at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source)
        at sun.awt.SunGraphicsCallback.runComponents(Unknown Source)
        at java.awt.Container.paint(Unknown Source)
        at jp.co.yokogawa.Stardom.UD.client.GrObjWnd.CSDUDGrObjWnd.paint(CSDUDGr
ObjWnd.java:708)
        at sun.awt.RepaintArea.paintComponent(Unknown Source)
        at sun.awt.RepaintArea.paint(Unknown Source)
        at sun.awt.windows.WComponentPeer.handleEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)

"TimerQueue" daemon prio=4 tid=0x05ef2a28 nid=0xff4 in Object.wait() [0x0d61f000
..0x0d61fbe8]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x2292b908> (a javax.swing.TimerQueue)
        at javax.swing.TimerQueue.run(Unknown Source)
        - locked <0x2292b908> (a javax.swing.TimerQueue)
        at java.lang.Thread.run(Unknown Source)

"QA Partner Java Extension Thread" prio=5 tid=0x07538e68 nid=0x7d4 runnable [0x0
83df000..0x083dfc68]
        at java.net.SocketInputStream.socketRead0(Native Method)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.net.SocketInputStream.read(Unknown Source)
        at java.io.DataInputStream.readInt(Unknown Source)
        at segue.io.XpMsgIn.<init>(XpMsgIn.java:113)
        at segue.io.EkPro.run(EkPro.java:450)

"Thread-6" prio=5 tid=0x07575dc0 nid=0x5ac runnable [0x00000000..0x00b5eb28]

"TimerQueue" daemon prio=5 tid=0x05f18a68 nid=0x840 in Object.wait() [0x074bf000
..0x074bfb68]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x228b4a80> (a javax.swing.TimerQueue)
        at javax.swing.TimerQueue.run(Unknown Source)
        - locked <0x228b4a80> (a javax.swing.TimerQueue)
        at java.lang.Thread.run(Unknown Source)

"AWT-EventQueue-0" prio=7 tid=0x05efb138 nid=0xd90 runnable [0x0709f000..0x0709f
c68]
        at sun.plugin.viewer.frame.IExplorerEmbeddedFrame.enableModeless(Native
Method)
        at sun.plugin.viewer.frame.IExplorerEmbeddedFrame.modalityPushed(Unknown
 Source)
        at sun.awt.windows.WToolkit$ModalityListenerList.modalityPushed(Unknown
Source)
        at sun.awt.windows.ModalityEvent.dispatch(Unknown Source)
        at sun.awt.windows.WToolkit.notifyModalityChange(Unknown Source)
        at sun.awt.windows.WDialogPeer.show(Unknown Source)
        at java.awt.Dialog.conditionalShow(Unknown Source)
        - locked <0x227b6a38> (a java.awt.Component$AWTTreeLock)
        at java.awt.Dialog.show(Unknown Source)
        at java.awt.Component.show(Unknown Source)
        at java.awt.Component.setVisible(Unknown Source)
        at com.sun.deploy.util.DialogFactory.internalShowAboutJavaDialog(Unknown
 Source)
        - locked <0x2846c270> (a java.lang.Class)
        at com.sun.deploy.util.DialogFactory.access$000(Unknown Source)
        at com.sun.deploy.util.DialogFactory$2.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)

"ConsoleWriterThread" daemon prio=7 tid=0x05efa4d8 nid=0xc0 in Object.wait() [0x
06e9f000..0x06e9fce8]
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Unknown Source)
        at com.sun.deploy.util.ConsoleTraceListener$ConsoleWriterThread.run(Unkn
own Source)
        - locked <0x2281b608> (a java.lang.Object)

"AWT-EventQueue-1" prio=7 tid=0x05ea12c8 nid=0x84c waiting for monitor entry [0x
06c9f000..0x06c9fd68]
        at java.awt.Component.invalidate(Unknown Source)
        - waiting to lock <0x227b6a38> (a java.awt.Component$AWTTreeLock)
        at java.awt.Container.invalidate(Unknown Source)
        at javax.swing.JComponent.revalidate(Unknown Source)
        at javax.swing.plaf.basic.BasicTextUI$RootView.preferenceChanged(Unknown
 Source)
        at javax.swing.text.View.preferenceChanged(Unknown Source)
        at javax.swing.text.PlainView.updateDamage(Unknown Source)
        at javax.swing.text.PlainView.removeUpdate(Unknown Source)
        at javax.swing.plaf.basic.BasicTextUI$RootView.removeUpdate(Unknown Sour
ce)
        at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.removeUpdate(Unknown
 Source)
        at javax.swing.text.AbstractDocument.fireRemoveUpdate(Unknown Source)
        at javax.swing.text.AbstractDocument.handleRemove(Unknown Source)
        at javax.swing.text.AbstractDocument.remove(Unknown Source)
        at javax.swing.text.AbstractDocument.replace(Unknown Source)
        at javax.swing.JTextArea.replaceRange(Unknown Source)
        at com.sun.deploy.util.ConsoleWindow$24.run(Unknown Source)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)

"traceMsgQueueThread" daemon prio=5 tid=0x05e92c58 nid=0xfac in Object.wait() [0
x0699f000..0x0699fa68]
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Unknown Source)
        at com.sun.deploy.util.Trace$TraceMsgQueueChecker.run(Unknown Source)
        - locked <0x2280bdb8> (a java.util.ArrayList)
        at java.lang.Thread.run(Unknown Source)

"AWT-Windows" daemon prio=7 tid=0x05e8add0 nid=0xf60 runnable [0x0668f000..0x066
8fae8]
        at sun.awt.windows.WToolkit.eventLoop(Native Method)
        at sun.awt.windows.WToolkit.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

"AWT-Shutdown" prio=5 tid=0x05e8a958 nid=0xe34 in Object.wait() [0x0648f000..0x0
648fb68]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x227b2098> (a java.lang.Object)
        at java.lang.Object.wait(Unknown Source)
        at sun.awt.AWTAutoShutdown.run(Unknown Source)
        - locked <0x227b2098> (a java.lang.Object)
        at java.lang.Thread.run(Unknown Source)

"Java2D Disposer" daemon prio=10 tid=0x05e898c0 nid=0x820 in Object.wait() [0x06
28f000..0x0628fbe8]
        at java.lang.Object.wait(Native Method)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        - locked <0x227b2120> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        at sun.java2d.Disposer.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

"Low Memory Detector" daemon prio=5 tid=0x02d53c20 nid=0x868 runnable [0x0000000
0..0x00000000]

"CompilerThread0" daemon prio=10 tid=0x02d52980 nid=0x80 waiting on condition [0
x00000000..0x05a5fa4c]

"Signal Dispatcher" daemon prio=10 tid=0x02d51be0 nid=0xc98 waiting on condition
 [0x00000000..0x00000000]

"Finalizer" daemon prio=9 tid=0x02d4ef00 nid=0xe54 in Object.wait() [0x0565f000.
.0x0565fa68]
        at java.lang.Object.wait(Native Method)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        - locked <0x227b22c8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(Unknown Source)
        at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)

"Reference Handler" daemon prio=10 tid=0x02d4da20 nid=0xe50 in Object.wait() [0x
0545f000..0x0545fae8]
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Unknown Source)
        at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
        - locked <0x227b1fd0> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x02cacd10 nid=0xf54 runnable [0x00000000..0x0013e7dc]

"VM Thread" prio=10 tid=0x02d4b180 nid=0x860 runnable

"VM Periodic Task Thread" prio=10 tid=0x02d55008 nid=0x828 waiting on condition
###@###.### 2005-06-11 00:25:06 GMT

A small test case was provided by an outside user which demostrates the same problem: 

Change the example.html of ArcTest demo applet to the following:
---

<html>
  <head>
      
<title>Arc Test (1.1)</title>
 




<script language="JavaScript">
<!--

function doLoad()
{
    // the timeout value should be the same as in the "refresh" meta-tag
    setTimeout( "refresh()", 2*1000 );
}

function refresh()
{
    //  This version of the refresh function will cause a new
    //  entry in the visitor's history.  It is provided for
    //  those browsers that only support JavaScript 1.0.
    //
    	document.location.reload();
	setTimeout( "refresh()", 2*1000 );
	
}
//-->
</script>




 </head>
  <body onload="doLoad()">
      <h1>Arc Test (1.1)</h1>
      <hr>
      <applet 

code=ArcTest.class width=400 height=400>
	alt="Your browser understands the <APPLET> tag but isn't running 

the applet, for some reason."
	Your browser is completely ignoring the <APPLET> tag!
      </applet>
      

<hr>
      <a href="ArcTest.java">The source</a>.
  </body>
</html>

This test hangs IE/plugin after few days of running.

Plugin native stack is similar. Plugin native and java stacks are attached.
###@###.### 2005-06-21 23:31:40 GMT

Comments
EVALUATION There exists a racing condition while diposing applets in IE plugin. To dispose an applet, AppletViewer starts a new thread to stop/destroy/quit applet. This thread disposes applet's threadgroup including the applet's Event Dispatcher Thread (EDT). On the other hand, the main thread is waiting for the embeded frame's destroy() to complete. The embedded frame calls windowClosing on the applet's EDT, which is already terminated. The racing between the above two threads (disposing applet's thread group and windowClosing on the EDT) can cause browser to hang when the EDT is stopped before the windowClosing is called. To address this problem, Hao suggested to make the sendEvent(APPLET_QUIT) call (this call is to dispose the applet's threadgroup) to wait for signals from embedded frame.destroy().
17-03-2006