Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7155957

closed/java/awt/MenuBar/MenuBarStress1/MenuBarStress1.java hangs on win 64 bit with jdk8

    Details

    • Subcomponent:
    • Resolved In Build:
      b68
    • CPU:
      x86
    • OS:
      windows

      Backports

        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

          Issue Links

            Activity

            Hide
            vdyakov Victor Dyakov added a comment - - edited
            is it dup of JDK-7155968 ??
            Show
            vdyakov Victor Dyakov added a comment - - edited is it dup of JDK-7155968 ??
            Hide
            bagiras Oleg Pekhovskiy (Inactive) added a comment -
            Adding defer request because such error happens only running this stress test and never in a real world.
            Show
            bagiras Oleg Pekhovskiy (Inactive) added a comment - Adding defer request because such error happens only running this stress test and never in a real world.
            Hide
            yan Yuri Nesterenko (Inactive) added a comment -
            jdk8: SQE OK to defer
            Show
            yan Yuri Nesterenko (Inactive) added a comment - jdk8: SQE OK to defer
            Hide
            vdyakov Victor Dyakov added a comment -
            RT NOTE:

            Client (bulk)

            The criteria for deferral bulk request bugs:
            - Not P2
            - Not tck-red
            - Not critical to customer

            Approved.
            Show
            vdyakov Victor Dyakov added a comment - RT NOTE: Client (bulk) The criteria for deferral bulk request bugs: - Not P2 - Not tck-red - Not critical to customer Approved.
            Hide
            ssadetsky Semyon Sadetsky added a comment -
            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.




            Show
            ssadetsky Semyon Sadetsky added a comment - 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.
            Hide
            ssadetsky Semyon Sadetsky added a comment -
            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.
            Show
            ssadetsky Semyon Sadetsky added a comment - 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.
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/1d8cae1d1c2c
            User: ssadetsky
            Date: 2015-05-08 14:35:37 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/client/jdk/rev/1d8cae1d1c2c User: ssadetsky Date: 2015-05-08 14:35:37 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/1d8cae1d1c2c
            User: lana
            Date: 2015-06-10 21:24:34 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/1d8cae1d1c2c User: lana Date: 2015-06-10 21:24:34 +0000

              People

              • Assignee:
                ssadetsky Semyon Sadetsky
                Reporter:
                vakulova Vera Akulova (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: