beanshell / beanshell

Beanshell scripting language
Apache License 2.0
815 stars 183 forks source link

GUI does not start in Java 8 #4

Closed stain closed 5 years ago

stain commented 8 years ago

Moved from https://code.google.com/a/apache-extras.org/p/beanshell/issues/detail?id=13

Reported by markbcrocker, Aug 19, 2015

To reproduce the problem:

java -jar bsh-2.0b5.jar

Expected and Actual Behavior

I expect to see a splash image followed by the console window. What I see instead is that the splash never finishes. There is never a console.

Platform

BeanShell 2.0b5 as provided by Maven Central repository running in JDK 1.8.0_51 (64-bit) on Window 7 Professional Service Pack 1.

Additional information

The problem occurs when running from a Command window, double clicking the jar and even from the command line in Cygwin. The exact same jar works just fine on JDK 1.7.0_u75.

stain commented 8 years ago

Also reproducible in Ubuntu 14.04 x64 with OpenJDK

stain@biggie:~/Downloads$ java -version 
openjdk version "1.8.0_45-internal"
OpenJDK Runtime Environment (build 1.8.0_45-internal-b14)
OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)

Thread dump (ctrl-) shows:

2015-09-24 08:54:49
Full thread dump OpenJDK 64-Bit Server VM (25.45-b02 mixed mode):

"TimerQueue" #17 daemon prio=5 os_prio=0 tid=0x00007fa15000a800 nid=0xdd7 waiting on condition [0x00007fa14acf7000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x000000076d315210> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
    at java.util.concurrent.DelayQueue.take(DelayQueue.java:211)
    at javax.swing.TimerQueue.run(TimerQueue.java:171)
    at java.lang.Thread.run(Thread.java:745)

"Thread-1" #16 prio=5 os_prio=0 tid=0x00007fa1ac4a8000 nid=0xdd6 in Object.wait() [0x00007fa14adf8000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000076e468a80> (a java.awt.EventQueue$1AWTInvocationLock)
    at java.lang.Object.wait(Object.java:502)
    at java.awt.EventQueue.invokeAndWait(EventQueue.java:1313)
    - locked <0x000000076e468a80> (a java.awt.EventQueue$1AWTInvocationLock)
    at java.awt.EventQueue.invokeAndWait(EventQueue.java:1294)
    at javax.swing.SwingUtilities.invokeAndWait(SwingUtilities.java:1348)
    at bsh.util.JConsole.invokeAndWait(JConsole.java:735)
    at bsh.util.JConsole.print(JConsole.java:493)
    at bsh.Interpreter.print(Interpreter.java:810)
    at bsh.Interpreter.run(Interpreter.java:460)
    at java.lang.Thread.run(Thread.java:745)

"Thread-0" #15 prio=5 os_prio=0 tid=0x00007fa1ac484800 nid=0xdd5 in Object.wait() [0x00007fa14aef9000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000076de59048> (a bsh.util.JConsole$BlockingPipedInputStream)
    at bsh.util.JConsole$BlockingPipedInputStream.read(JConsole.java:771)
    - locked <0x000000076de59048> (a bsh.util.JConsole$BlockingPipedInputStream)
    at java.io.PipedInputStream.read(PipedInputStream.java:377)
    - locked <0x000000076de59048> (a bsh.util.JConsole$BlockingPipedInputStream)
    at java.io.InputStream.read(InputStream.java:101)
    at bsh.util.JConsole.inPipeWatcher(JConsole.java:667)
    at bsh.util.JConsole.run(JConsole.java:677)
    at java.lang.Thread.run(Thread.java:745)

"AWT-EventQueue-0" #13 prio=6 os_prio=0 tid=0x00007fa1ac341800 nid=0xdd3 waiting for monitor entry [0x00007fa18811a000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.awt.Component.invalidate(Component.java:2926)
    - waiting to lock <0x000000076cc2e9e0> (a java.awt.Component$AWTTreeLock)
    at java.awt.Container.invalidate(Container.java:1585)
    at javax.swing.JComponent.revalidate(JComponent.java:4857)
    at javax.swing.plaf.basic.BasicTextUI$RootView.preferenceChanged(BasicTextUI.java:1406)
    at javax.swing.text.View.preferenceChanged(View.java:288)
    at javax.swing.text.BoxView.preferenceChanged(BoxView.java:286)
    at javax.swing.text.View.preferenceChanged(View.java:288)
    at javax.swing.text.BoxView.preferenceChanged(BoxView.java:286)
    at javax.swing.text.View.preferenceChanged(View.java:288)
    at javax.swing.text.View.preferenceChanged(View.java:288)
    at javax.swing.text.GlyphView.insertUpdate(GlyphView.java:926)
    at javax.swing.text.View.forwardUpdateToView(View.java:1227)
    at javax.swing.text.FlowView$LogicalView.forwardUpdateToView(FlowView.java:795)
    at javax.swing.text.View.forwardUpdate(View.java:1162)
    at javax.swing.text.FlowView$LogicalView.forwardUpdate(FlowView.java:805)
    at javax.swing.text.View.insertUpdate(View.java:710)
    at javax.swing.text.FlowView.insertUpdate(FlowView.java:255)
    at javax.swing.text.View.forwardUpdateToView(View.java:1227)
    at javax.swing.text.View.forwardUpdate(View.java:1162)
    at javax.swing.text.BoxView.forwardUpdate(BoxView.java:240)
    at javax.swing.text.View.insertUpdate(View.java:710)
    at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(BasicTextUI.java:1610)
    at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.java:1869)
    at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:201)
    at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:748)
    at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:707)
    at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:669)
    at javax.swing.JTextPane.replaceSelection(JTextPane.java:192)
    at javax.swing.JTextPane.replaceSelection(JTextPane.java:175)
    at bsh.util.JConsole.append(JConsole.java:367)
    at bsh.util.JConsole.access$300(JConsole.java:57)
    at bsh.util.JConsole$2.run(JConsole.java:495)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:301)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

"AWT-Shutdown" #12 prio=5 os_prio=0 tid=0x00007fa1ac33f800 nid=0xdd2 in Object.wait() [0x00007fa18821d000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000076d100fc0> (a java.lang.Object)
    at java.lang.Object.wait(Object.java:502)
    at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:295)
    - locked <0x000000076d100fc0> (a java.lang.Object)
    at java.lang.Thread.run(Thread.java:745)

"AWT-XAWT" #11 daemon prio=6 os_prio=0 tid=0x00007fa1ac327000 nid=0xdd1 runnable [0x00007fa18831e000]
   java.lang.Thread.State: RUNNABLE
    at sun.awt.X11.XToolkit.waitForEvents(Native Method)
    at sun.awt.X11.XToolkit.run(XToolkit.java:568)
    at sun.awt.X11.XToolkit.run(XToolkit.java:532)
    at java.lang.Thread.run(Thread.java:745)

"Java2D Disposer" #9 daemon prio=10 os_prio=0 tid=0x00007fa1ac2ff000 nid=0xdd0 in Object.wait() [0x00007fa18882f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000076cca8cb8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
    - locked <0x000000076cca8cb8> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
    at sun.java2d.Disposer.run(Disposer.java:148)
    at java.lang.Thread.run(Thread.java:745)

"Service Thread" #8 daemon prio=9 os_prio=0 tid=0x00007fa1ac17a000 nid=0xdce runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007fa1ac176800 nid=0xdcd waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007fa1ac175000 nid=0xdcc waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007fa1ac172000 nid=0xdcb waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007fa1ac170000 nid=0xdca waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007fa1ac145800 nid=0xdc9 in Object.wait() [0x00007fa18b3f2000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000076cb86f58> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
    - locked <0x000000076cb86f58> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007fa1ac143800 nid=0xdc8 in Object.wait() [0x00007fa18b4f3000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000076cb86998> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:157)
    - locked <0x000000076cb86998> (a java.lang.ref.Reference$Lock)

"main" #1 prio=5 os_prio=0 tid=0x00007fa1ac00a000 nid=0xdc2 in Object.wait() [0x00007fa1b4f2e000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000076de1d338> (a javax.swing.text.DefaultStyledDocument)
    at java.lang.Object.wait(Object.java:502)
    at javax.swing.text.AbstractDocument.readLock(AbstractDocument.java:1387)
    - locked <0x000000076de1d338> (a javax.swing.text.DefaultStyledDocument)
    at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:908)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1662)
    at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1332)
    at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:791)
    at java.awt.Container.layout(Container.java:1508)
    at java.awt.Container.doLayout(Container.java:1497)
    at java.awt.Container.validateTree(Container.java:1693)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validateTree(Container.java:1702)
    at java.awt.Container.validate(Container.java:1628)
    - locked <0x000000076cc2e9e0> (a java.awt.Component$AWTTreeLock)
    at java.awt.Container.validateUnconditionally(Container.java:1665)
    - locked <0x000000076cc2e9e0> (a java.awt.Component$AWTTreeLock)
    at java.awt.Window.show(Window.java:1033)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at bsh.Reflect.invokeMethod(Reflect.java:131)
    at bsh.Reflect.invokeObjectMethod(Reflect.java:77)
    at bsh.Name.invokeMethod(Name.java:852)
    at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:69)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:96)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:41)
    at bsh.BSHBlock.evalBlock(BSHBlock.java:125)
    at bsh.BSHBlock.eval(BSHBlock.java:75)
    at bsh.BshMethod.invokeImpl(BshMethod.java:356)
    at bsh.BshMethod.invoke(BshMethod.java:252)
    at bsh.BshMethod.invoke(BshMethod.java:180)
    at bsh.Name.invokeLocalMethod(Name.java:952)
    at bsh.Name.invokeMethod(Name.java:798)
    at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:69)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:96)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:41)
    at bsh.Interpreter.eval(Interpreter.java:659)
    at bsh.Interpreter.eval(Interpreter.java:750)
    at bsh.Interpreter.eval(Interpreter.java:739)
    at bsh.Console.main(Console.java:47)

"VM Thread" os_prio=0 tid=0x00007fa1ac13e800 nid=0xdc7 runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007fa1ac01f000 nid=0xdc3 runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007fa1ac020800 nid=0xdc4 runnable 

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007fa1ac022800 nid=0xdc5 runnable 

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007fa1ac024000 nid=0xdc6 runnable 

"VM Periodic Task Thread" os_prio=0 tid=0x00007fa1ac198800 nid=0xdcf waiting on condition 

JNI global references: 523

Heap
 PSYoungGen      total 74752K, used 28402K [0x000000076cb80000, 0x0000000771e80000, 0x00000007c0000000)
  eden space 64512K, 44% used [0x000000076cb80000,0x000000076e73cbf8,0x0000000770a80000)
  from space 10240K, 0% used [0x0000000771480000,0x0000000771480000,0x0000000771e80000)
  to   space 10240K, 0% used [0x0000000770a80000,0x0000000770a80000,0x0000000771480000)
 ParOldGen       total 171008K, used 0K [0x00000006c6200000, 0x00000006d0900000, 0x000000076cb80000)
  object space 171008K, 0% used [0x00000006c6200000,0x00000006c6200000,0x00000006d0900000)
 Metaspace       used 13920K, capacity 14146K, committed 14336K, reserved 1062912K
  class space    used 1653K, capacity 1735K, committed 1792K, reserved 1048576K
stain commented 8 years ago

It seems the deadlock is in java.awt.Component$AWTTreeLock caused by the AWT-EventQueue-0 thread being in the middle of updating the JConsole log and AWT redrawing the graphics (called by EventQueue.invokeAndWait in the interpreter thread Thread-1), while the main thread is trying to start up by invoking some beanshell script calling Window.show() - it seems the same window as the block is on 0x000000076cc2e9e0 on both threads.

pejobo commented 8 years ago

See https://github.com/pejobo/beanshell2/issues/38

stain commented 8 years ago

Thanks, @pejobo - are you able to re-contribute your patch to this repository? I am unable to copy it myself as pejobo/beanshell is LGPL licensed, while contributiions to beanshell/beanshell will need to be covered by the Apache Software License. You are however the copyrightholder (presumably) and can do so. :)

nickl- commented 5 years ago

beanshell2 fix merged at beanshell/beanshell@17fbd0a

jiangyd commented 5 years ago

@nickl- do you know ,why? image

pejobo commented 5 years ago

A stacktrace or threaddump would be helpful

fabrizziosoares commented 5 years ago

Any solution?

pejobo commented 5 years ago

I can reproduce this, this is the relevant trace:

"main" #1 prio=5 os_prio=0 tid=0x00007fe48400b800 nid=0x7e79 in Object.wait() [0x00007fe48d968000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x00000007596533b8> (a javax.swing.text.DefaultStyledDocument)
    at java.lang.Object.wait(Object.java:502)
    at javax.swing.text.AbstractDocument.readLock(AbstractDocument.java:1387)
    - locked <0x00000007596533b8> (a javax.swing.text.DefaultStyledDocument)
    at javax.swing.plaf.basic.BasicTextUI.getPreferredSize(BasicTextUI.java:908)
    at javax.swing.JComponent.getPreferredSize(JComponent.java:1662)
    at javax.swing.JEditorPane.getPreferredSize(JEditorPane.java:1333)
    at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:791)
    at java.awt.Container.layout(Container.java:1513)
    at java.awt.Container.doLayout(Container.java:1502)
    at java.awt.Container.validateTree(Container.java:1698)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validateTree(Container.java:1707)
    at java.awt.Container.validate(Container.java:1633)
    - locked <0x000000075828fcd0> (a java.awt.Component$AWTTreeLock)
    at java.awt.Container.validateUnconditionally(Container.java:1670)
    - locked <0x000000075828fcd0> (a java.awt.Component$AWTTreeLock)
    at java.awt.Window.show(Window.java:1033)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at bsh.Reflect.invokeMethod(Reflect.java:131)
    at bsh.Reflect.invokeObjectMethod(Reflect.java:77)
    at bsh.Name.invokeMethod(Name.java:852)
    at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:69)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:96)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:41)
    at bsh.BSHBlock.evalBlock(BSHBlock.java:125)
    at bsh.BSHBlock.eval(BSHBlock.java:75)
    at bsh.BshMethod.invokeImpl(BshMethod.java:356)
    at bsh.BshMethod.invoke(BshMethod.java:252)
    at bsh.BshMethod.invoke(BshMethod.java:180)
    at bsh.Name.invokeLocalMethod(Name.java:952)
    at bsh.Name.invokeMethod(Name.java:798)
    at bsh.BSHMethodInvocation.eval(BSHMethodInvocation.java:69)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:96)
    at bsh.BSHPrimaryExpression.eval(BSHPrimaryExpression.java:41)
    at bsh.Interpreter.eval(Interpreter.java:659)
    at bsh.Interpreter.eval(Interpreter.java:750)
    at bsh.Interpreter.eval(Interpreter.java:739)
    at bsh.Console.main(Console.java:47)
pejobo commented 5 years ago

I checked bsh-2.b06.jar, it still contains the broken desktop.bsh code (path bsh/commands/desktop.bsh).

pejobo commented 5 years ago

Nor does the actual master branch :( You could use the version here, which includes the fix: https://github.com/pejobo/beanshell2/tree/v2.1/dist

nickl- commented 5 years ago

@pejobo are you moving that beanshell2 branch again!?!?!

Why don't you just come over and help us here, do a complete merge projects and all?

The more the merrier, what do you say?

nickl- commented 5 years ago

@jiangyd missed you there, would've been bette to open a new issue but no harm done.

I will need to have a closer look before commenting, issue is now open again.

opeongo commented 5 years ago

I cannot reproduce this problem with the current master of bsh-3.0.0-SNAPSHOT.jar using java version "9.0.4". The BeanShell desktop starts up quickly and displays a working workspace JConsole window.

nickl- commented 5 years ago

@opeongo Did you test this on Windows?

Can we double click the jar to run the console?

opeongo commented 5 years ago

@nickl Yes I tested this on Windows 7 64 Pro. Yes, double clicking on the jar file starts the BeanShell Desktop.

nickl- commented 5 years ago

Thank you!

Closed: Cannot reproduce