JDK-4971236 : SWAT: Java2D demo SizeRequirements.calculateTiledPositions() overflows allocated
  • Type: Bug
  • Component: client-libs
  • Sub-Component: demo
  • Affected Version: 5.0,6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS:
    generic,linux_suse_sles_8,solaris,solaris_10,windows_2003 generic,linux_suse_sles_8,solaris,solaris_10,windows_2003
  • CPU: generic,x86,sparc
  • Submitted: 2003-12-19
  • Updated: 2013-05-22
  • Resolved: 2005-11-21
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 6
6 b62Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
When running Java2D demo on AMD64-SLES, lots of java.lang.NullPointerException is thrown.
-----------------------
java.lang.NullPointerException
        at javax.swing.SizeRequirements.calculateTiledPositions(SizeRequirements.java:294)
        at javax.swing.BoxLayout.layoutContainer(BoxLayout.java:378)
        at javax.swing.JToolBar$DefaultToolBarLayout.layoutContainer(JToolBar.java:786)
        at java.awt.Container.layout(Container.java:1398)
        at java.awt.Container.doLayout(Container.java:1388)
        at java.awt.Container.validateTree(Container.java:1470)
        at java.awt.Container.validateTree(Container.java:1477)
        at java.awt.Container.validateTree(Container.java:1477)
        at java.awt.Container.validateTree(Container.java:1477)
        at java.awt.Container.validateTree(Container.java:1477)
        at java.awt.Container.validateTree(Container.java:1477)
        at java.awt.Container.validateTree(Container.java:1477)
        at java.awt.Container.validateTree(Container.java:1477)
        at java.awt.Container.validate(Container.java:1445)
        at javax.swing.plaf.basic.BasicTabbedPaneUI.ensureCurrentLayout(BasicTabbedPaneUI.java:1215)
        at javax.swing.plaf.basic.BasicTabbedPaneUI.paint(BasicTabbedPaneUI.java:530)
        at javax.swing.plaf.metal.MetalTabbedPaneUI.paint(MetalTabbedPaneUI.java:827)
        at javax.swing.plaf.metal.MetalTabbedPaneUI.update(MetalTabbedPaneUI.java:716)
        at javax.swing.JComponent.paintComponent(JComponent.java:714)
        at javax.swing.JComponent.paint(JComponent.java:977)
        at javax.swing.JComponent.paintChildren(JComponent.java:814)
        at javax.swing.JComponent.paint(JComponent.java:986)
        at javax.swing.JComponent.paintChildren(JComponent.java:814)
        at javax.swing.JComponent.paint(JComponent.java:986)
        at javax.swing.JComponent.paintChildren(JComponent.java:814)
        at javax.swing.JComponent.paint(JComponent.java:986)
        at javax.swing.JLayeredPane.paint(JLayeredPane.java:559)
        at javax.swing.JComponent.paintChildren(JComponent.java:814)
        at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4882)
        at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4828)
        at javax.swing.JComponent.paint(JComponent.java:967)
        at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
        at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
        at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
        at java.awt.Container.paint(Container.java:1704)
        at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
        at sun.awt.X11.XRepaintArea.paintComponent(XRepaintArea.java:56)
        at sun.awt.RepaintArea.paint(RepaintArea.java:224)
        at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:632)
        at java.awt.Component.dispatchEventImpl(Component.java:4007)
        at java.awt.Container.dispatchEventImpl(Container.java:2019)
        at java.awt.Window.dispatchEventImpl(Window.java:1757)
        at java.awt.Component.dispatchEvent(Component.java:3779)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
        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)
-----------------------

System tested:
bunt
SuSE SLES-8 (AMD64)
VERSION = 8.1
Linux bunt 2.4.19-SMP #1 SMP Mon Mar 31 23:48:08 UTC 2003 x86_64 unknown

STEP TO REPRODUCE:
------------------
1. install SWAT b32 bundle rpm.bin bundle on AMD64-SLES machine
2. invoke the Java2D demo
3. open the "run windows" pop-up window and let it run for 10 times.

###@###.### 2003-12-19

The bug still reproducible in b63 SWAT testing.
###@###.### 2004-08-11

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: dragon
17-09-2004

EVALUATION Where are the SWAT bundles? In the meantime I will try to reproduce this manually on a SLES machine. ###@###.### 2003-12-22 This stack trace indicates that something has gone wrong in populating the xChildren array in BoxLayout.java. It should never be the case that the array contains null items. The theory that I investigated was that perhaps a RuntimeException was being thrown while populating this array (in the method checkRequests()). If this were the case then the array may not be populated correctly, resulting in null items which could cause an NPE later. In order to test this theory, I modified BoxLayout.java as follows: *** /tmp/geta18764 Mon Jan 26 14:49:53 2004 --- BoxLayout.java Mon Jan 26 14:44:44 2004 *************** *** 417,422 **** --- 417,423 ---- } void checkRequests() { + try { if (xChildren == null || yChildren == null) { // The requests have been invalidated... recalculate // the request information. *************** *** 452,457 **** --- 453,469 ---- yTotal = SizeRequirements.getTiledSizeRequirements(yChildren); } } + } catch (RuntimeException re) { + if (!SwingUtilities.isEventDispatchThread()) { + System.err.println("not on EDT!!!"); + System.err.println(Thread.currentThread()); + re.printStackTrace(); + } else { + System.err.println("okay, we're on the EDT!!!"); + } + System.err.println("now throwing exception..."); + throw re; + } } /** The purpose of this modification was to print out to the console if any RuntimeException occurs that causes population of the array to be prematurely aborted. I then ran an application that was displaying this problem, Java2Demo, and got the following stack output: okay, we're on the EDT!!! now throwing exception... java.lang.NullPointerException at java.awt.Dimension.<init>(Dimension.java:91) at java.awt.Component.getMaximumSize(Component.java:2325) at java.awt.Container.getMaximumSize(Container.java:1622) at javax.swing.JComponent.getMaximumSize(JComponent.java:1579) at javax.swing.BoxLayout.checkRequests(BoxLayout.java:436) at javax.swing.BoxLayout.layoutContainer(BoxLayout.java:375) at javax.swing.JToolBar$DefaultToolBarLayout.layoutContainer(JToolBar.ja va:786) at java.awt.Container.layout(Container.java:1398) at java.awt.Container.doLayout(Container.java:1388) at java.awt.Container.validateTree(Container.java:1470) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validate(Container.java:1445) at java2d.DemoGroup.setup(DemoGroup.java:257) at java2d.GlobalPanel.stateChanged(GlobalPanel.java:102) at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:283) at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:2 15) at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingl eSelectionModel.java:116) at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingl eSelectionModel.java:50) at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:471) at javax.swing.JTabbedPane.setSelectedIndex(JTabbedPane.java:457) at javax.swing.plaf.basic.BasicTabbedPaneUI$Handler.mousePressed(BasicTa bbedPaneUI.java:3192) at java.awt.Component.processMouseEvent(Component.java:5462) at javax.swing.JComponent.processMouseEvent(JComponent.java:3052) at java.awt.Component.processEvent(Component.java:5230) at java.awt.Container.processEvent(Container.java:1961) at java.awt.Component.dispatchEventImpl(Component.java:3933) at java.awt.Container.dispatchEventImpl(Container.java:2019) at java.awt.Component.dispatchEvent(Component.java:3781) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4203 ) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3880) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3813) at java.awt.Container.dispatchEventImpl(Container.java:2005) at java.awt.Window.dispatchEventImpl(Window.java:1757) at java.awt.Component.dispatchEvent(Component.java:3781) at java.awt.EventQueue.dispatchEvent(EventQueue.java:463) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:234) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.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) java.lang.NullPointerException at javax.swing.SizeRequirements.calculateTiledPositions(SizeRequirements .java:294) at javax.swing.BoxLayout.layoutContainer(BoxLayout.java:378) at javax.swing.JToolBar$DefaultToolBarLayout.layoutContainer(JToolBar.ja va:786) at java.awt.Container.layout(Container.java:1398) at java.awt.Container.doLayout(Container.java:1388) at java.awt.Container.validateTree(Container.java:1470) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validateTree(Container.java:1477) at java.awt.Container.validate(Container.java:1445) at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.j ava:354) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(System EventQueueUtilities.java:116) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:201) at java.awt.EventQueue.dispatchEvent(EventQueue.java:461) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh read.java:234) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre ad.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) This output confirms the hypothesis above. A NullPointerException is being thrown in Component.getMaximumSize(), which causes checkRequests() to fail before completing. Investigation into the cause of the NPE shows a problem with the synchronization of the min/max/pref size methods in Component. See 4984970 and 4988378 for more information. Closing 4984970 as a duplicate of this. Also contacting ###@###.### and asking that the issue be tracked under this (earlier) bug number - which would mean also closing 4988378 as a duplicate of this. ###@###.### 2004-02-17 Name: agR10216 Date: 02/10/2004 I've seen this bug by pure accident, and I think I know its primary cause. See the bug 4984970. ###@###.### 2004-02-10 ====================================================================== Name: agR10216 Date: 02/19/2004 The following suggestion was sent to ###@###.### on February 18, 2004: ASG> The primary cause of the bugs 4971236 and 4984970 is the fact ASG> that Java2Demo accesses GUI after Swing components have been ASG> realized from the main thread. You know, the Swing tutorial ASG> strongly recommends not to do this. ASG> Even if the AWT bug 4988378 were fixed, there might be some ASG> problems, since JComponent overrides the methods in question ASG> {get|set}{Minimum|Preferred|Maximum}Size() and lacks for any ASG> synchronization. ASG> So I'd suggest revising the demo (perhaps any other demos that ASG> violate "The Single-Thread Rule") under the bug 4971236 and keeping ASG> 4988378 open for AWT, we'll fix 4988378 later as this bug isn't ASG> critical for applications which adhere to the rule. ###@###.### 2004-02-19 ====================================================================== Name: rpR10076 Date: 02/19/2004 Whereever the bug is, we should try to address it in tiger. We need to fix the demo and, if possible, fix our implementation. ###@###.### ====================================================================== Name: agR10216 Date: 02/20/2004 There haven't been any objections from ###@###.###, so with ###@###.###'s approval, I'm recategorizing this bug to demo_2d to have the demo revised in accord with "The Single-Thread Rule" for tiger. The AWT synchronization issue will be fixed under the bug 4988378 for tiger too. ###@###.### 2004-02-20 ====================================================================== From Praveen.Mohan This requires the threading model in Java2Demo to be fixed. This requires lot of effort and code change. This is as good as rewriting the demo. So it is not possible for Tiger. Moreover the root cause of this bug resembles 4965892 and hence this could be a duplicate. I would require some more time to find out whether this is really a duplicate of 4965892. In any case, this is not something that is introduced recently and has been existing right from the begining. So probably we may wish to lower the priority at least for tiger. Name: agR10216 Date: 02/27/2004 Yes, this bug is a duplicate of 4965892, as well as 4984970. So there are (at least) 3 bugs on the same issue filed against different subcategories. Shouldn't the issue be fixed ASAP not to produce more duplicates? Note, changing a demo isn't a risky fix. Even if the AWT synchronization is fixed (under the bug 4988378), there may well be some threading problems because Swing isn't thread safe definitely. Why on earth should demo apps bundled with JDK violate rules of our own, stated in docs and tutorials? All demos should have been revised to strictly follow Swing's "single-thread rule" ages ago! ###@###.### 2004-02-27 ======================================================================
27-02-2004