JDK-6887286 : StackOverflowError at sun.awt.image.ImageWatched$WeakLink.isWatcher
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6u10
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2009-10-01
  • Updated: 2017-05-19
  • Resolved: 2011-11-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.
JDK 8
8 b14Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Client VM (build 11.2-b01, mixed mode, sharing)

Encountered in 1.6.0_7 to 1.6.0_13, may happen in earlier and newer version as well


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.0.6001]


EXTRA RELEVANT SYSTEM CONFIGURATION :
We did not encounter this Error on WindowsXP, but this may be just coincidence.

A DESCRIPTION OF THE PROBLEM :
The following Error is raised occasionally under Windows Vista in applications with a (Swing) GUI.

Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
...

The application is in an almost unresponsive state then.
We had this error several times on different machines running Windows Vista without a recognizable relationship to the user activity. Well, it *seems* to happen more often after some inactivity.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
No safe way to reproduce. Perhaps, run a Swing application more complex than hello world and wait...



ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
	at sun.awt.image.ImageWatched$WeakLink.isWatcher(ImageWatched.java:84)
...

REPRODUCIBILITY :
This bug can be reproduced occasionally.

Comments
Verified b114
07-11-2013

2D_Image/ImageWatchedStackOverflowTest
01-07-2013

EVALUATION Issue is caused by a memory leak. We assume that anytime we call startProduction() on an ImageProducer, it will eventually call imageComplete() indicating that the image is finished loading (i.e. STATICIMAGEDONE), that the load failed (IMAGEERROR or IMAGEABORTED), or the image source will continue to regularly call imageComplete() with SINGLEFAMEDONE (resulting in regular pruning of the WatchedImage's linked list to remove WeakLink:s that correspond to null WeakReferences or disinterested ImageObservers). Unfortunately, in the case of OffScreenImageSource we never do that (we only call imageComplete() with SINGLEAMEDONE once and then stop forever), so the ImageRepresentation is left in a state where it believes it is still waiting for more data that never actually comes (the consuming field is left set to true.) All subsequent calls to startProduction() become noops and as a result, ImageWatched.newInfo() is never called. Since we depend on calls to newInfo() to remove uninterested ImageObserver objects (or null WeakReferences that GC has cleaned up for us) from the linked list that ImageWatched keeps, we have indefinite growth of this linked list. When we use recursion to iterate over this list, we can run out of stack space.
06-10-2011