United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-5062191 : NPE in Win32SurfaceData.initOps when exiting appletviewer on Swing applet

Details
Type:
Bug
Submit Date:
2004-06-11
Status:
Open
Updated Date:
2008-11-18
Project Name:
JDK
Resolved Date:
Component:
client-libs
OS:
windows_nt,windows_xp
Sub-Component:
2d
CPU:
x86
Priority:
P4
Resolution:
Unresolved
Affected Versions:
5.0,6
Targeted Versions:

Related Reports
Duplicate:
Duplicate:
Relates:

Sub Tasks

Description
Version: Tiger b54
System: Dual Processor x86
OS: Windows NT 4

\> cd demos
\> cd jfc
\> cd SwingSet2
\> appletviewer SwingSet2.html
When SwingSet has finished loading, hit the X to close the window.

\> cd demos
\> cd jfc
\> cd SwingApplet
appletviewer SwingApplet.html
When the applet has finished loading, hit X to close the window.

In both cases, the following exception is printed on the console:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: component argument pData
        at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
        at sun.awt.windows.Win32SurfaceData.<init>(Win32SurfaceData.java:448)
        at sun.awt.windows.Win32SurfaceData.createData(Win32SurfaceData.java:316)
        at sun.awt.Win32GraphicsConfig.createSurfaceData(Win32GraphicsConfig.java:357)
        at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:326)
        at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:307)
        at sun.awt.windows.WComponentPeer$2.run(WComponentPeer.java:347)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        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)

                                    

Comments
EVALUATION

Note that it appears that 2D doesn't use the native peer data correctly,
at least, on windows.

Prior to getting the pData we should first obtain a global
lock, otherwise other thread may dispose the native component's data.

In Win32SurfaceData_GetWindow() we call Win32SurfaceData_GetComp()
which retrieves a pointer to AwtComponent from the peer object,
and this pointer is then used to get the insets. A thread
could dispose the native data at any time since we don't
hold any locks, and we'll die when dereferencing.
                                     
2006-12-27
EVALUATION

I believe the bug is fixed with my change in WComponentPeer.
The change is a part of the fix for 6255371. The change
is to post an invocation event (which replaces the surface 
data associated with the component) to the event dispatch thread
of the app context, to which the current component belongs.
Previously all such invocation events were posted to the event 
dispatch thread of the main app context and a thread race
might result in NullPointerException.

Note the bug is not easily reproducible, so I can't verify 
whether it's fixed. The bug may be closed if it is not 
reproducible any more.
                                     
2006-04-03
EVALUATION

I don't have a dual CPU machine any more and it's therefore very hard to see if this is gone. Does anyone else have a machine to test this out on?
                                     
2006-04-03
EVALUATION

The bug is reproducible all the way since b18 (don't have
the earlier builds handy), but not on 1.4.2, as far as I can tell.

Also, I've only been able to reproduce it on Windows dual-cpu systems
(I've reproduced it on both windows-i586 and windows-amd64).

I wouldn't call it a tiger showstopper, as the exception seems to be
harmless - we detect a null data pointer and throw the exception. 
It's possible that applets running in browser can throw
it as well when the user leaves the page - I haven't tried this
yet.

###@###.### 2004-06-17
                                     
2004-06-17



Hardware and Software, Engineered to Work Together