JDK-6535349 : NPE in DrawGlyphList when terminating an application on Win32
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2007-03-16
  • Updated: 2011-03-17
  • Resolved: 2011-03-17
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
7Resolved
Related Reports
Relates :  
Relates :  
Description
I am running the attached test on JDK7-b02 and I am getting a NPE when pressing CTRL+C on the console. This test basically creates a Frame for each GraphicsConfig available on the GraphicsDevice and renders some 2D graphics on to a canvas added to each of the frames.

This exception is not reproducible on JDK6-FCS and JDK7-b01 whereas it is reproducible on JDK7-b02. Also repoducible on JDK7-b10 AWT PIT build. This is specific to win32 and not reproducible on SolSparc10. I am filing it against AWT since AWT integrated into b02 and 2D did not.

Here is the exception-

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: HDC for component
at sun.java2d.loops.DrawGlyphList.DrawGlyphList(Native Method)
at sun.java2d.pipe.SolidTextRenderer.drawGlyphList(SolidTextRenderer.java:23)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:54)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2753)
at GCCanvas.paint(ScreenStandaloneTest.java:111)
at java.awt.Canvas.update(Canvas.java:114)
at sun.awt.RepaintArea.updateComponent(RepaintArea.java:239)
at sun.awt.RepaintArea.paint(RepaintArea.java:216)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:301)
at java.awt.Component.dispatchEventImpl(Component.java:4484)
at java.awt.Component.dispatchEvent(Component.java:4238)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121) 

I have attached a test - ScreenStandaloneTest.java. Compile and run it. When all the frames are loaded (around 26 on my machine), press CTRL+C on the console. you will get the above exception.

Comments
EVALUATION I don't think this is a regression, this thread race existed prior to 7.0 early builds. Most probably the fix for 6387273 has changed the timings, so the race became more easy to reproduce.
21-03-2007

EVALUATION I have added some println statements to the Win32SurfaceData.cpp code: before the check AwtToolkit::GetInstance().VerifyActive(), before beingShutdown is set to true in the exception handler and before NPE is thrown. When the test is terminated correctly, the sequence of calls is the following: check for VerifyActive() catch exception and set beingShutdown = TRUE no NPE is thrown Another sequence is when the NPE is observed: NPE is thrown - one or several times check for VerifyActive() catch exception and set beingShutdown = TRUE The key issue here is that VerifyActive() was not called before NPE is thrown, thus beingShutdown flag was not updated.
21-03-2007

EVALUATION The reason beingShutdown is TRUE is that AwtToolkit::GetInstance().VerifyActive(); now throws an exception - see Win32SurfaceData_GetComp() method in Win32SurfaceData.cpp. This used not to happen prior to AWT integration. If the semantics or behavior of VerifyActive changed, please explain (would have been nice if we were notified in advance..) Reassigning back to AWT.
20-03-2007

EVALUATION I'm able to reproduce this NPE on my WinXP box. However, I doubt this is an AWT issue, even though Java2D team had no integration into b02 (don't forget about a bunch of latest 6.0 builds forwardported to 7.0-b02) The only place in our code where 'HDC for component' exception is thrown is in Win32SurfaceData::Win32SD_Lock native method (Java2D code). This throw statement is surrounded by 'if (beingShutdown != JNI_TRUE)' which must be false for the given test, but it is true for some reason. So I feel this is Java2D issue and dispatching it to them.
20-03-2007