JDK-4943231 : Regression test EventQueue/PushPopDeadlock fails
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0,5.0u7
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux,solaris_9
  • CPU: x86,sparc
  • Submitted: 2003-10-24
  • Updated: 2008-01-24
  • Resolved: 2008-01-24
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
Name: dmR10075			Date: 10/24/2003



Regression test test/java/awt/EventQueue/PushPopDeadlock failes with
1.5.0b24 on RH9 with the following stack trace:
"AWT-EventQueue-1" prio=1 tid=0x081f6248 nid=0x74bb waiting for monitor
entry [0x4fc82000..0x4fc8297c]
        at java.awt.EventQueue.getNextEvent(EventQueue.java:333)
        - waiting to lock <0x42e20490> (a PushPopDeadlock$3)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:174)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
 
"AWT-EventQueue-2" prio=1 tid=0x081f60c8 nid=0x74ba waiting for monitor
entry [0x4fc02000..0x4fc02bfc]
        at java.awt.EventQueue.postEventPrivate(EventQueue.java:190)
        - waiting to lock <0x43780af8> (a java.awt.EventQueue)
        at java.awt.EventQueue.postEvent(EventQueue.java:175)
        at sun.awt.PostEventQueue.flush(SunToolkit.java:993)
        - locked <0x43776368> (a sun.awt.PostEventQueue)
        at sun.awt.SunToolkit.flushPendingEvents(SunToolkit.java:510)
        at java.awt.EventQueue.getNextEvent(EventQueue.java:332)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:174)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
 
"AWT-EventQueue-1" prio=1 tid=0x081f77d0 nid=0x74b9 in Object.wait()
[0x4fd02000..0x4fd02c7c]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x42e20490> (a PushPopDeadlock$3)
        at java.lang.Object.wait(Object.java:429)
        at java.awt.EventQueue.getNextEvent(EventQueue.java:345)
        - locked <0x42e20490> (a PushPopDeadlock$3)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:174)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at
java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
 
"Thread-2" prio=1 tid=0x08194f18 nid=0x7498 in Object.wait()
[0x4facf000..0x4facfafc]
        at java.lang.Object.wait(Native Method)
        - waiting on <0x42de3030> (a java.awt.EventDispatchThread)
        at java.lang.Thread.join(Thread.java:1016)
        - locked <0x42de3030> (a java.awt.EventDispatchThread)
        at java.lang.Thread.join(Thread.java:1069)
        at
java.awt.EventDispatchThread.stopDispatchingImpl(EventDispatchThread.java:76)
        at
java.awt.EventDispatchThread.stopDispatching(EventDispatchThread.java:91)
        at java.awt.EventQueue.pop(EventQueue.java:642)
        at java.awt.EventQueue.pop(EventQueue.java:612)
        - locked <0x42e20490> (a PushPopDeadlock$3)
        - locked <0x43780af8> (a java.awt.EventQueue)
        at PushPopDeadlock$3.push(PushPopDeadlock.java:74)
        at PushPopDeadlock$4.run(PushPopDeadlock.java:92)
        at java.lang.Thread.run(Thread.java:549)

"AWT-XAWT" daemon prio=1 tid=0x08181b60 nid=0x7493 waiting for monitor
entry [0x4f9cf000..0x4f9cf8fc]
        at java.awt.EventQueue.wakeup(EventQueue.java:853)
        - waiting to lock <0x43780af8> (a java.awt.EventQueue)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at sun.awt.SunToolkit.wakeupEventQueue(SunToolkit.java:265)
        at sun.awt.PostEventQueue.postEvent(SunToolkit.java:1014)
        at sun.awt.SunToolkit.postEvent(SunToolkit.java:497)
        at sun.awt.X11.XWindow.postEvent(XWindow.java:335)
        at sun.awt.X11.XWindow.postEventToEventQueue(XWindow.java:344)
        at sun.awt.X11.XWindow.handleMotionNotify(XWindow.java:637)
        at sun.awt.X11.XBaseWindow.dispatchEvent(XBaseWindow.java:780)
        at
sun.awt.X11.XBaseWindow.dispatchToWindow(XBaseWindow.java:749)
        at sun.awt.X11.XToolkit.dispatchEvent(XToolkit.java:391)
        at sun.awt.X11.XToolkit.run(XToolkit.java:479)
        at sun.awt.X11.XToolkit.run(XToolkit.java:435)
        at java.lang.Thread.run(Thread.java:549)
 
======================================================================
###@###.### 10/4/04 16:54 GMT

Comments
EVALUATION Name: osR10079 Date: 10/27/2003 I was unable to reproduce the problem with EventQueue/PushPopDeadlock test, but here is result of investigation of provided threads dump. The problem is as follows: we have three queues (system(sqe) and two custom(eq1, eq2)). we call pop() on eq1, it gets loks on sqe and q1 and calls pop() on q2. This call does some stuff (like moving events, clearing fields etc.) and then calls EventDispatchThread.stopDispatching() (btw this call should be called without any locks, but in our case we have such locks from eq1.pop(). EventDispatchThread.stopDispatching() marks EDT as closed and joins to it. This is a "short" history from one thread. If, at the same time (somewhen after eq1.pop() is called), we call EventQueue.postEvent()(or getNextEvent()) on EDT associated with eq2, it calls SunTooklit.flushPendingEvents() and if there are some pending events then SunToolkit will call postEvent() on system event queue (seq), which, in turn, will try to get lock on seq. But this lock is owned by the first thread, which is joining this EDT now. So we have a deadlock. Here is a testcase a testcase which reproduces this problem in 100% runs. ------------------- PushPopTest.java ------------------------------- import java.awt.*; import java.awt.event.*; import java.util.EmptyStackException; import sun.awt.SunToolkit; public class PushPopTest { public static Frame frame; public static void main(String[] args) { frame = new Frame(""); frame.pack(); Runnable dummy = new Runnable() { public void run() { System.err.println("Dummy is here."); } }; EventQueue seq = Toolkit.getDefaultToolkit().getSystemEventQueue(); MyEventQueue1 eq1 = new MyEventQueue1(); MyEventQueue2 eq2 = new MyEventQueue2(); EventQueue.invokeLater(dummy); seq.push(eq1); EventQueue.invokeLater(dummy); eq1.push(eq2); EventQueue.invokeLater(dummy); Runnable runnable = new Runnable() { public void run() { System.err.println("Dummy from SunToolkit"); } }; InvocationEvent ie = new InvocationEvent(eq2, runnable, null, false); System.err.println(ie); SunToolkit.postEvent(SunToolkit.targetToAppContext(frame), ie); eq1.pop(); System.exit(0); } } class MyEventQueue1 extends EventQueue { public void pop() throws EmptyStackException { super.pop(); } } class MyEventQueue2 extends EventQueue { protected void pop() throws EmptyStackException { System.err.println("pop2()"); Thread.dumpStack(); try { EventQueue.invokeAndWait(new Runnable() { public void run() { Runnable runnable = new Runnable() { public void run() { System.err.println("Dummy from here"); } }; InvocationEvent ie = new InvocationEvent(MyEventQueue2.this, runnable, null, false); SunToolkit.postEvent(SunToolkit.targetToAppContext(PushPopTest.frame), ie); postEvent(ie); } }); } catch (InterruptedException ie) { ie.printStackTrace(); } catch (java.lang.reflect.InvocationTargetException ie) { ie.printStackTrace(); } super.pop(); } } ------------------- end of PushPopTest.java ------------------------------- Using this test I found that the problem is reproducible with 1.3, 1.3.1, 1.4.X and tiger. So, this is not a regression for 1.4.X. ###@###.### 2003-10-28 ====================================================================== ###@###.### 10/4/04 16:54 GMT
28-10-2003