Deadlock in JConsole possible?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Deadlock in JConsole possible?

Jens-Uwe Mager
I have been using BeanShell in a Swing application where I did embed a
JConsole to be able to peek and poke at the internal state. This is all
fine and well if I issue commands that print from the seperate thread
that I did create, but if I issue prints that produce large output from
for example a menu item in my debug menu I get the following deadlock
and the complete swing GUI freezes:

"Thread-6" prio=5 tid=0x0325f8d0 nid=0xef0 in Object.wait() [0x0387f000..0x0387f
9e8]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x22b8e530> (a java.awt.EventQueue$1AWTInvocationLock)
        at java.lang.Object.wait(Unknown Source)
        at java.awt.EventQueue.invokeAndWait(Unknown Source)
        - locked <0x22b8e530> (a java.awt.EventQueue$1AWTInvocationLock)
        at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
        at bsh.util.JConsole.invokeAndWait(Unknown Source)
        at bsh.util.JConsole.print(Unknown Source)
        at bsh.util.JConsole.inPipeWatcher(Unknown Source)
        at bsh.util.JConsole.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

"AWT-EventQueue-0" prio=7 tid=0x02cfe410 nid=0xa08 in Object.wait() [0x0301d000.
.0x0301fbe8]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x234b3d90> (a bsh.util.JConsole$BlockingPipedInputStream)

        at java.io.PipedInputStream.awaitSpace(Unknown Source)
        at java.io.PipedInputStream.receive(Unknown Source)
        - locked <0x234b3d90> (a
          bsh.util.JConsole$BlockingPipedInputStream)
        at java.io.PipedOutputStream.write(Unknown Source)
        at java.io.PrintStream.write(Unknown Source)
        - locked <0x234b3db8> (a java.io.PrintStream)
        at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(Unknown Source)
        at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(Unknown Source)
        at sun.nio.cs.StreamEncoder.flushBuffer(Unknown Source)
        - locked <0x234b5190> (a java.io.OutputStreamWriter)
        at java.io.OutputStreamWriter.flushBuffer(Unknown Source)
        at java.io.PrintStream.write(Unknown Source)
        - locked <0x234b3db8> (a java.io.PrintStream)
        at java.io.PrintStream.print(Unknown Source)
        at bsh.Interpreter.print(Unknown Source)
        at bsh.Interpreter.println(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at bsh.Reflect.invokeMethod(Unknown Source)
        at bsh.Reflect.invokeObjectMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHIfStatement.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BshMethod.invokeImpl(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.Name.invokeLocalMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BshMethod.invokeImpl(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.Name.invokeLocalMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at bsh.Reflect.invokeMethod(Unknown Source)
        at bsh.Reflect.invokeObjectMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHReturnStatement.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BshMethod.invokeImpl(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.Name.invokeLocalMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BSHTryStatement.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BshMethod.invokeImpl(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.This.invokeMethod(Unknown Source)
        at bsh.This.invokeMethod(Unknown Source)
        at bsh.XThis$Handler.invokeImpl(Unknown Source)
        at bsh.XThis$Handler.invoke(Unknown Source)
        at $Proxy0.actionPerformed(Unknown Source)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.AbstractButton.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown
Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(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.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.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)

Is there any way to avoid that kind of deadlock?

--
Jens-Uwe Mager <pgp-mailto:F476EBC2>


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
Beanshell-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/beanshell-users
Reply | Threaded
Open this post in threaded view
|

Re: Deadlock in JConsole possible?

Marc DENTY
----- Message Original -----
De: Jens-Uwe Mager [hidden email]
A: [hidden email]
Envoyé: 19.07.2005 16:59:06
Sujet: [Beanshell-users] Deadlock in JConsole possible?



I have been using BeanShell in a Swing application where I did embed a
JConsole to be able to peek and poke at the internal state. This is all
fine and well if I issue commands that print from the seperate thread
that I did create, but if I issue prints that produce large output from
for example a menu item in my debug menu I get the following deadlock
and the complete swing GUI freezes:

"Thread-6" prio=5 tid=0x0325f8d0 nid=0xef0 in Object.wait() [0x0387f000..0x0387f
9e8]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x22b8e530> (a java.awt.EventQueue$1AWTInvocationLock)
        at java.lang.Object.wait(Unknown Source)
        at java.awt.EventQueue.invokeAndWait(Unknown Source)
        - locked <0x22b8e530> (a java.awt.EventQueue$1AWTInvocationLock)
        at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
        at bsh.util.JConsole.invokeAndWait(Unknown Source)
        at bsh.util.JConsole.print(Unknown Source)
        at bsh.util.JConsole.inPipeWatcher(Unknown Source)
        at bsh.util.JConsole.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)

"AWT-EventQueue-0" prio=7 tid=0x02cfe410 nid=0xa08 in Object.wait() [0x0301d000.
.0x0301fbe8]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x234b3d90> (a bsh.util.JConsole$BlockingPipedInputStream)

        at java.io.PipedInputStream.awaitSpace(Unknown Source)
        at java.io.PipedInputStream.receive(Unknown Source)
        - locked <0x234b3d90> (a
          bsh.util.JConsole$BlockingPipedInputStream)
        at java.io.PipedOutputStream.write(Unknown Source)
        at java.io.PrintStream.write(Unknown Source)
        - locked <0x234b3db8> (a java.io.PrintStream)
        at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(Unknown Source)
        at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer(Unknown Source)
        at sun.nio.cs.StreamEncoder.flushBuffer(Unknown Source)
        - locked <0x234b5190> (a java.io.OutputStreamWriter)
        at java.io.OutputStreamWriter.flushBuffer(Unknown Source)
        at java.io.PrintStream.write(Unknown Source)
        - locked <0x234b3db8> (a java.io.PrintStream)
        at java.io.PrintStream.print(Unknown Source)
        at bsh.Interpreter.print(Unknown Source)
        at bsh.Interpreter.println(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at bsh.Reflect.invokeMethod(Unknown Source)
        at bsh.Reflect.invokeObjectMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHIfStatement.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BshMethod.invokeImpl(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.Name.invokeLocalMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BshMethod.invokeImpl(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.Name.invokeLocalMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at bsh.Interpreter.eval(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at bsh.Reflect.invokeMethod(Unknown Source)
        at bsh.Reflect.invokeObjectMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHReturnStatement.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BshMethod.invokeImpl(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.Name.invokeLocalMethod(Unknown Source)
        at bsh.Name.invokeMethod(Unknown Source)
        at bsh.BSHMethodInvocation.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHPrimaryExpression.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BSHTryStatement.eval(Unknown Source)
        at bsh.BSHBlock.evalBlock(Unknown Source)
        at bsh.BSHBlock.eval(Unknown Source)
        at bsh.BshMethod.invokeImpl(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.BshMethod.invoke(Unknown Source)
        at bsh.This.invokeMethod(Unknown Source)
        at bsh.This.invokeMethod(Unknown Source)
        at bsh.XThis$Handler.invokeImpl(Unknown Source)
        at bsh.XThis$Handler.invoke(Unknown Source)
        at $Proxy0.actionPerformed(Unknown Source)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.AbstractButton.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
        at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown
Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(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.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.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)

Is there any way to avoid that kind of deadlock?

  
As a Swing component JConsole cannot be modified ouside the AWT-EventQueue thread

Please see documentation : http://www.beanshell.org/manual/jconsole.html

Tip:

When interacting with any Swing component from outside the Java event handling thread, use the Swing thread safety facilities: SwingUtilities.invokeNow() and invokeLater().


Hope this helps.

--Marc
------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ Beanshell-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/beanshell-users