JDK-7155957 : closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • CPU: x86
  • Submitted: 2012-03-22
  • Updated: 2018-02-08
  • Resolved: 2015-05-08
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 JDK 7 JDK 8 JDK 9 Other
6u151Fixed 7u141Fixed 8u131Fixed 9 b68Fixed openjdk7uFixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
test closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java failed on windows 64 bit with jdk 8, passed with 7u4b15 on same machine, passed with jdk 8 on solaris and linux

test machines:
stt-62.ru, stt-44.ru - win xp 64 bit
stt-67.ru - win 2008 64 bit

see comments for more details

Comments
The solution introduces number of fixes in various Java and C++ classes are introduced to eliminate (with finite probability) concurrency problems : 1. java.awt.Menu.remove(int) The peer.delItem(index) is called after mi.removeNotify(). That means that dispose event will be sent earlier than the menu remove WinAPI call. This causes Access Violation exception because Windows events may come with deallocated references. The solution is to call them in the right order. 2. java.awt.MenuBar.remove(int) Same error as in 1 for menu bar. 3. java.awt.MenuComponent.serFont(Font) This method should hold tree lock while running otherwise its concurrent execution causes Access Violation in number of places and JVM is crashed. 4. awt_Menu.cpp AwtMenu::GetItem(jobject target, jint index), AwtMenu::DrawItems(), AwtMenu::MeasureItems( Calling java.awt.Menu.getItem() during internal windows event processing can throw ArrayIndexOutOfBoundException because number of menu items could be changed concurrently and the index is not in range. This causes a hidden exception which is only seen in debug mode as an Assertion error. Another issue here is request to GetPeerForTarget() for the menu item peer which can be concurrently deleted on the Java side as result of Menu.delNotify() execution. It causes NPE peer which is also hidden and only reveals itself as an Assertion error in debug mode. The solution for all is to abort and return windows event callback if the menu structure was changed concurrently. 5. awt_MenuBar.cpp AwtMenuBar::GetItem() Same solution as 4 for menu bar in similar situations. 6. awt_MenuItem.cpp AwtMenuItem::Dispose() The "destroyed" filed should be set for the peer before pData is set to NULL otherwise "NPE null pData" can be thrown in various concurrent situations. 7. awt_new.cpp safe_ExceptionOccurred() This routine is called evrywere in the code to check exceptions. It only stops execution and prints to console if OOE happened, but other exceptions are re-thrown silently and execution continues without any warnings. If a call is initiated by the internal Windows event callback exceptions are hidden in the release mode and shown in the debug mode as an Assertion Error message box, but in the last case without any useful information because GetLastError() is always 0 in such situations. I have added env->ExceptionDescribe() to print exception stack trace on the console for all debug and release modes. This should help to detect internal toolkit issues during testing by JCK and jtreg. Later before the JDK9 release we can leave it for debug mode only. *A KNOWN PROBLEM DID NOT FIXED When font is assigned to a menu item concurrently there is a big chance that menu item size will be calculated with one font while drawing of the item will be performed with another font. In such situation label of the menu item does not fit its size or vice versa. This is due to the nature how the Windows OS handles owner-drawn menus.
16-04-2015

This is AWT concurrency issue. setFont/getFont need to be synchronized by the tree lock and probably other similar methods as well. Exceptions are hidden silently in the native code because assertion errors are not shown. For example : DASSERT(!safe_ExceptionOccurred(env)) will not show any warnings because it checks exception for assertion and re-throws it but usually the exceptions are not checked after that anymore. When I add env->ExceptionDescribe() I got plenty of them in the console like NPE peer, ArrayOutOfBound etc all are related to unsafe concurrent execution.
10-04-2015

RT NOTE: Client (bulk) The criteria for deferral bulk request bugs: - Not P2 - Not tck-red - Not critical to customer Approved.
11-10-2013

jdk8: SQE OK to defer
08-10-2013

Adding defer request because such error happens only running this stress test and never in a real world.
08-10-2013

is it dup of JDK-7155968 ??
03-10-2013