JDK-4972974 : XAWT: XAllocSizeHints() is called without holding AWT_LOCK
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86
  • Submitted: 2003-12-27
  • Updated: 2008-11-05
  • Resolved: 2004-01-16
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.
Other
5.0 b35Fixed
Related Reports
Relates :  
Description

Name: agR10216			Date: 12/27/2003


Run the following test on Linux using java_g from the tiger build 32
(without any parameters) and see an InternalError.
-----------------------------------------------------
import java.awt.*;

public class WindowTest {
    public static void main(String args[]) {
        Frame f = new Frame();
        Window w = new Window(f);
        f.setSize(300, 200);
        w.setSize(300, 200);
        f.setLocationByPlatform(true);
        w.setLocationByPlatform(true);
        (args.length == 0 ? w : f).setVisible(true);
    }
}
-----------------------------------------------------
Exception in thread "main" java.lang.InternalError: Following Thread does not have AWT_LOCK !!!!!

        at sun.awt.X11.XlibWrapper.XAllocSizeHints(Native Method)
        at sun.awt.X11.XBaseWindow.getHints(XBaseWindow.java:345)
        at sun.awt.X11.XWindowPeer.promoteDefaultPosition(XWindowPeer.java:578)
        at sun.awt.X11.XWindowPeer.setVisible(XWindowPeer.java:586)
        at sun.awt.X11.XComponentPeer.show(XComponentPeer.java:453)
        at java.awt.Component.show(Component.java:1260)
        at java.awt.Window.show(Window.java:512)
        at java.awt.Component.show(Component.java:1292)
        at java.awt.Component.setVisible(Component.java:1247)
        at WindowTest.main(WindowTest.java:11)
-----------------------------------------------------

###@###.### 2003-12-27
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: tiger-beta2 FIXED IN: tiger-beta2 INTEGRATED IN: tiger-b35 tiger-beta2
24-08-2004

SUGGESTED FIX Name: atR10251 Date: 01/16/2004 filelist: - src/solaris/classes/sun/awt/X11/XWindowPeer.java - src/solaris/classes/sun/awt/X11/XBaseWindow.java ------- XWindowPeer.java ------- *** /tmp/sccs.TLaqOo Mon Jan 5 19:21:03 2004 --- XWindowPeer.java Mon Jan 5 19:16:12 2004 *************** *** 572,585 **** XLayerProtocol.LAYER_NORMAL); } private void promoteDefaultPosition() { if (((Window)target).isLocationByPlatform()) { ! Rectangle bounds = getBounds(); ! XSizeHints hints = getHints(); ! setSizeHints(hints.get_flags() & ~(USPosition | PPosition), ! bounds.x, bounds.y, bounds.width, bounds.height); } } public void setVisible(boolean vis) { updateFocusability(); --- 572,587 ---- XLayerProtocol.LAYER_NORMAL); } private void promoteDefaultPosition() { if (((Window)target).isLocationByPlatform()) { ! synchronized (getAWTLock()) { ! Rectangle bounds = getBounds(); ! XSizeHints hints = getHints(); ! setSizeHints(hints.get_flags() & ~(USPosition | PPosition), ! bounds.x, bounds.y, bounds.width, bounds.height); ! } } } public void setVisible(boolean vis) { updateFocusability(); ------- XBaseWindow.java ------- *** /tmp/sccs.ZZaiXE Mon Jan 5 19:42:18 2004 --- XBaseWindow.java Mon Jan 5 19:41:16 2004 *************** *** 337,347 **** } return wmHints; } ! public XSizeHints getHints() { if (hints == null) { long p_hints = XlibWrapper.XAllocSizeHints(); hints = new XSizeHints(p_hints); // XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), getWindow(), p_hints, XlibWrapper.larg1); --- 337,350 ---- } return wmHints; } ! /* ! * Call this method under AWTLock. ! * The lock should be acquired untill all operations with XSizeHints are completed. ! */ public XSizeHints getHints() { if (hints == null) { long p_hints = XlibWrapper.XAllocSizeHints(); hints = new XSizeHints(p_hints); // XlibWrapper.XGetWMNormalHints(XToolkit.getDisplay(), getWindow(), p_hints, XlibWrapper.larg1); ###@###.### 2004-01-16 ======================================================================
16-01-2004

EVALUATION Name: atR10251 Date: 12/30/2003 <XBaseWindow.getHints> should acquire AWT_LOCK. ###@###.### 2003-12-30 ====================================================================== Name: atR10251 Date: 01/05/2004 The suggestion above was wrong. <XBaseWindow.getHints> was implemented with the assumption that in time when "get" and "set" operations with XSizeHints structure take place AWTLock should be acquired. So this method doesn't have to acquire the lock but should be called under it. ###@###.### 2004-01-05 ======================================================================
05-01-2004