Recursive StackOverFlow in Java client aplication

Hi,

We run into this recursive stackoverflow problem in our Swing + AWT + BWT client application. We could not pin point what GUI action caused this stackoverflow problem yet. We are currently trying to reset the stack size, see if we can find out the beginning of the stack trace, hope it will show what action caused this. At the mean time, can someone please shed some lights here on what was going on, and how to solve the problem? Thanks in advance.

-Zihong

OS: windows XP

JDK: 1.5.0_08

The exception stack trace is:

java.lang.StackOverflowError

at java.util.Hashtable.put(Hashtable.java:401)

at sun.java2d.Disposer.add(Disposer.java:101)

at sun.java2d.Disposer.addRecord(Disposer.java:69)

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:332)

at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:313)

at sun.awt.windows.WComponentPeer.displayChanged(WComponentPeer.java:372)

at sun.awt.windows.WCanvasPeer.displayChanged(WCanvasPeer.java:48)

at sun.awt.windows.WPanelPeer.displayChanged(WPanelPeer.java:142)

at sun.awt.windows.WPanelPeer.recursiveDisplayChanged(WPanelPeer.java:130)

at sun.awt.windows.WPanelPeer.displayChanged(WPanelPeer.java:145)

at sun.awt.windows.WPanelPeer.recursiveDisplayChanged(WPanelPeer.java:130)

at sun.awt.windows.WPanelPeer.displayChanged(WPanelPeer.java:145)

at sun.awt.windows.WPanelPeer.recursiveDisplayChanged(WPanelPeer.java:130)

at sun.awt.windows.WPanelPeer.displayChanged(WPanelPeer.java:145)

at sun.awt.windows.WPanelPeer.recursiveDisplayChanged(WPanelPeer.java:130)

at sun.awt.windows.WPanelPeer.displayChanged(WPanelPeer.java:145)

...

...

[2093 byte] By [zihonga] at [2007-11-27 2:41:33]
# 1
You're not putting the map into itself, as a key or value?
pm_kirkhama at 2007-7-12 3:05:27 > top of Java-index,Java Essentials,Java Programming...
# 2
The hash code of a hashtable changes every time there's a change to it, due to the fact that equals() and hashCode() examine the entire content. Hence, you shouldn't be using it as a key or value. yc
ycliana at 2007-7-12 3:05:27 > top of Java-index,Java Essentials,Java Programming...
# 3

Hi, pm_kirkham and yc,

Thanks for replies.

No, we did not put map itself as the key or value. We should be able to reproduce the case easily if there is anything like that in our code - it should not even pass our unit test.

However, I will examine the relevent area,see if we use a hashtable as key, in another map. I highly doubt this is the cause. Again, things like this is very easy to reproduce.

From the earlier part of the stack track, you can easily see that it is Sun's java code that recursively does

at sun.awt.windows.WPanelPeer.displayChanged(WPanelPeer.java:145)

at sun.awt.windows.WPanelPeer.recursiveDisplayChanged(WPanelPeer.java:130)

until the end, where the hashtable comes into play, calling into the win32 native code, and throw StackOverflow exception.

-Zihong

zihonga at 2007-7-12 3:05:27 > top of Java-index,Java Essentials,Java Programming...
# 4

When we increased the stack trace limit to infinite (-XX:MaxJavaStackTraceDepth=0), we found the cause for this recursive problem:

...

...

at sun.awt.windows.WPanelPeer.recursiveDisplayChanged(Unknown Source)

at sun.awt.windows.WPanelPeer.displayChanged(Unknown Source)

at sun.awt.windows.WWindowPeer.displayChanged(Unknown Source)

at sun.awt.SunDisplayChanger.notifyListeners(Unknown Source)

at sun.awt.Win32GraphicsDevice.displayChanged(Unknown Source)

at sun.awt.Win32GraphicsEnvironment.displayChanged(Unknown Source)

at sun.awt.windows.WToolkit$4.run(Unknown Source)

at java.awt.event.InvocationEvent.dispatch(Unknown Source)

at java.awt.EventQueue.dispatchEvent(Unknown Source)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.pumpEvents(Unknown Source)

at java.awt.EventDispatchThread.run(Unknown Source)

Exception in thread "AWT-EventQueue-0"

We suspect this occured when users was using windows XP remote desktop to access the client machine that ran the client application, which caused the windows resolution to change, so the call to Win32GraphicsEnvironment.displayChanged.The display change caused infinite loop of recursive calls.

That seems to be a bug in Sun's java implementation.

zihonga at 2007-7-12 3:05:27 > top of Java-index,Java Essentials,Java Programming...