JDK-6834576 : PIT: closed/java/awt/ScrollPane/RemoveChild/ test fail with deadlock on rhel and sles
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2009-04-27
  • Updated: 2011-01-19
  • Resolved: 2009-11-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b60Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
jdk: /net/spb-cyclops/export/IntegrationBuilds/7/2009-04-27-042403.ss145989.jdk7-swing-pit-with-awt/

reg test: closed/java/awt/ScrollPane/RemoveChild/ fail on sles and rhel5 x86 on jdk7b57_awt_swing_pit

It fails on jdk 7 b53 too.

jstack log attached(ScrollPaneRemoveAdd.jstack).

How to reproduce.(Not always reproduced 90%)
1 Login to computer
2 cd /tmp/tempresults
3 export DISPLAY=:0
4 xhost +
5 jct-tools3.1.2/linux/bin/jtreg -jdk:/export/jdk/jdk1.7.0_pit_b57/ -verbose:all  test/closed/java/awt/ScrollPane/RemoveChild/ -automatic -timeout:15

Found one Java-level deadlock:
=============================
"Thread-2":
  waiting for ownable synchronizer 0xb333a7f0, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),
  which is held by "AWT-XAWT"
"AWT-XAWT":
  waiting to lock monitor 0x082150b8 (object 0xb33d99b0, a sun.awt.X11.XToolkit),
  which is held by "AppletThread"
"AppletThread":
  waiting for ownable synchronizer 0xb333a7f0, (a java.util.concurrent.locks.ReentrantLock$NonfairSync),
  which is held by "AWT-XAWT" 

A few tests fails with similar stack. Also attached:
jstack_16318
jstack_18898
jstack_19816
jstack_2539

Comments
SUGGESTED FIX +++ b/src/solaris/classes/sun/awt/X11/XToolkit.java Mon Nov 23 13:54:40 2009 +0300 @@ -1455,7 +1455,7 @@ public final class XToolkit extends UNIX * (which is assigned to the virtual pointer) reports the maximum * capabilities of the mouse pointer (i.e. 32 physical buttons). */ - private native synchronized int getNumberOfButtonsImpl(); + private native int getNumberOfButtonsImpl(); @Override public int getNumberOfButtons(){
23-11-2009

EVALUATION The deadlock is between Applet (owns toolkit lock and attempt to acquire awtLock) and the toolkit threads (opposite order). The toolkit thread require it just because it's about to query the number of buttons from the X system and it already owns awtlock. By some reason, its native method has synchronized modifier but shouldn't. We couldn't find the environment to test it yet.
23-11-2009

EVALUATION The suggestion is to keep the number of buttons required for MouseEvent CTOR in the SunToolkit itself (specifically, provide it by request in the XToolkit and WToolkit accessor). That allow us to move the time to aquire the number from the native system to the earlier moment of time.
13-05-2009

EVALUATION Toolkit thread holds awtLock and then MouseEvent.clinit aquires Toolkit-class lock. Simultaneusly, AppletThread holds Toolkit-class lock and tries to aquire awtLock. By the time we load the MouseEvent class and initialize its static field within the synchronization section, the Toolkit class has alredy picked required property from the native system.
30-04-2009

EVALUATION It's a regression of the fix for 6315717 (Support For Mouse With Multiple Scroll Wheels and 4 or More Buttons). For convenienve, the stack traces of the threads involved into the deadlock are listed below "Thread-2": at sun.misc.Unsafe.park(Native Method) - parking to wait for <0xb333a7f0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197) at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290) at sun.awt.SunToolkit.awtLock(SunToolkit.java:262) at sun.awt.X11.XAtom.<init>(XAtom.java:265) at sun.awt.X11.XAtom.<init>(XAtom.java:232) at sun.awt.X11.XAtom.get(XAtom.java:178) at sun.awt.X11.XSystemTrayPeer.<clinit>(XSystemTrayPeer.java:52) at sun.awt.X11.XToolkit$2.run(XToolkit.java:311) "AWT-XAWT": at java.awt.Toolkit.getDesktopProperty(Toolkit.java:1778) - waiting to lock <0xb33d99b0> (a sun.awt.X11.XToolkit) at java.awt.MouseInfo.getNumberOfButtons(MouseInfo.java:124) at java.awt.event.MouseEvent.<clinit>(MouseEvent.java:420) at sun.awt.X11.XWindow.handleXCrossingEvent(XWindow.java:978) at sun.awt.X11.XBaseWindow.dispatchEvent(XBaseWindow.java:1103) at sun.awt.X11.XBaseWindow.dispatchToWindow(XBaseWindow.java:1063) at sun.awt.X11.XToolkit.dispatchEvent(XToolkit.java:534) at sun.awt.X11.XToolkit.run(XToolkit.java:643) at sun.awt.X11.XToolkit.run(XToolkit.java:564) at java.lang.Thread.run(Thread.java:717) "AppletThread": at sun.misc.Unsafe.park(Native Method) - parking to wait for <0xb333a7f0> (a java.util.concurrent.locks.ReentrantLock$NonfairSync) at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186) at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:834) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:867) at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197) at java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:214) at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:290) at sun.awt.SunToolkit.awtLock(SunToolkit.java:262) at sun.awt.X11.XToolkit.initializeMultiClickTime(XToolkit.java:1270) at sun.awt.X11.XToolkit.getMultiClickTime(XToolkit.java:1265) at sun.awt.X11.XToolkit.initializeDesktopProperties(XToolkit.java:1434) at java.awt.Toolkit.getDesktopProperty(Toolkit.java:1784) - locked <0xb33d99b0> (a sun.awt.X11.XToolkit) at sun.swing.SwingUtilities2$AATextInfo.getAATextInfo(SwingUtilities2.java:133) at javax.swing.plaf.metal.MetalLookAndFeel.initComponentDefaults(MetalLookAndFeel.java:1559) at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:147) at javax.swing.plaf.metal.MetalLookAndFeel.getDefaults(MetalLookAndFeel.java:1594) at javax.swing.UIManager.setLookAndFeel(UIManager.java:548) at javax.swing.UIManager.setLookAndFeel(UIManager.java:588) at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1344) at javax.swing.UIManager.initialize(UIManager.java:1433) at javax.swing.UIManager.maybeInitialize(UIManager.java:1421) - locked <0xb34628f0> (a java.lang.Object) at javax.swing.UIManager.getDefaults(UIManager.java:662) at javax.swing.UIManager.getColor(UIManager.java:704) at com.sun.java.swing.plaf.motif.MotifBorders$BevelBorder.<init>(MotifBorders.java:60) at com.sun.java.swing.plaf.motif.MotifLookAndFeel.initComponentDefaults(MotifLookAndFeel.java:209) at sun.awt.X11.XAWTLookAndFeel.initComponentDefaults(XAWTLookAndFeel.java:86) at javax.swing.plaf.basic.BasicLookAndFeel.getDefaults(BasicLookAndFeel.java:147) at sun.awt.X11.XToolkit.initUIDefaults(XToolkit.java:259) at sun.awt.X11.XToolkit.getUIDefaults(XToolkit.java:239) at sun.awt.X11.XScrollPanePeer.<clinit>(XScrollPanePeer.java:47) at sun.awt.X11.XToolkit.createScrollPane(XToolkit.java:990) at java.awt.ScrollPane.addNotify(ScrollPane.java:560) - locked <0xb330e218> (a java.awt.Component$AWTTreeLock) at java.awt.Container.addImpl(Container.java:1086) - locked <0xb330e218> (a java.awt.Component$AWTTreeLock) at java.awt.Container.add(Container.java:399) at ScrollPaneRemoveAdd.init(ScrollPaneRemoveAdd.java:49) at com.sun.javatest.regtest.AppletWrapper$AppletThread.run(AppletWrapper.java:132) at java.lang.Thread.run(Thread.java:717)
28-04-2009