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

Intermittent NPE in JLightweightFrame when updating cursor across multiple graphics devices

    XMLWordPrintable

Details

    • b23
    • x86_64
    • linux

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_144"
      Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
      Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux localhost.localdomain 4.11.11-300.fc26.x86_64 #1 SMP Mon Jul 17 16:32:11 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      When running a JavaFX application on a machine with multiple display devices, we occasionally see NPEs in the application thread. The exception stack traces contain NONE of our code. It appears that JavaFX sometimes cannot tell which graphics device contains the current mouse position, at which point MouseInfo.getPointerInfo() returns null. JLightweightFrame.java:473 then tries to dereference this null as it tries to update the client cursor.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      This bug requires multiple graphics devices, and is intermittent anyway. Here is our original bug report:

      https://github.com/corda/corda/issues/1049

      Basically, we were running a JavaFX application on a laptop connected to a projector, with the laptop running PowerPoint and flipping in and out of fullscreen mode.

      And this is our fix:

      https://github.com/corda/corda/pull/1069

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expect the application thread not to throw NPEs.
      ACTUAL -
      The JavaFX application stops responding and a large exception stack trace appears in the log file.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      We use the JetBrains fork of OpenJDK, but this bug exists upstream too.

      2017-07-14T12:44:16,277 [ERROR] ErrorHandler - Uncaught error
      java.lang.NullPointerException: null
      at sun.swing.JLightweightFrame.updateClientCursor(JLightweightFrame.java:473) ~[?:1.8.0_152-release]
      at sun.swing.JLightweightFrame.access$000(JLightweightFrame.java:79) ~[?:1.8.0_152-release]
      at sun.swing.JLightweightFrame$1.updateCursor(JLightweightFrame.java:112) ~[?:1.8.0_152-release]
      at sun.lwawt.LWLightweightFramePeer.updateCursorImmediately(LWLightweightFramePeer.java:117) ~[?:1.8.0_152-release]
      at java.awt.Component.updateCursorImmediately(Component.java:3156) ~[?:1.8.0_152-release]
      at java.awt.Container.validate(Container.java:1643) ~[?:1.8.0_152-release]
      at java.awt.Window.dispatchEventImpl(Window.java:2744) ~[?:1.8.0_152-release]
      at java.awt.Component.dispatchEvent(Component.java:4719) ~[?:1.8.0_152-release]
      at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764) ~[?:1.8.0_152-release]
      at java.awt.EventQueue.access$500(EventQueue.java:98) ~[?:1.8.0_152-release]
      at java.awt.EventQueue$3.run(EventQueue.java:715) ~[?:1.8.0_152-release]
      at java.awt.EventQueue$3.run(EventQueue.java:709) ~[?:1.8.0_152-release]
      at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_152-release]
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) ~[?:1.8.0_152-release]
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90) ~[?:1.8.0_152-release]
      at java.awt.EventQueue$4.run(EventQueue.java:737) ~[?:1.8.0_152-release]
      at java.awt.EventQueue$4.run(EventQueue.java:735) ~[?:1.8.0_152-release]
      at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_152-release]
      at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80) ~[?:1.8.0_152-release]
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:734) ~[?:1.8.0_152-release]
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201) [?:1.8.0_152-release]
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) [?:1.8.0_152-release]
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) [?:1.8.0_152-release]
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:1.8.0_152-release]


      REPRODUCIBILITY :
      This bug can be reproduced occasionally.

      CUSTOMER SUBMITTED WORKAROUND :
      diff --git a/src/share/classes/sun/swing/JLightweightFrame.java b/src/share/classes/sun/swing/JLightweightFrame.java
      index c8882e45f..5f4e4431e 100644
      --- a/src/share/classes/sun/swing/JLightweightFrame.java
      +++ b/src/share/classes/sun/swing/JLightweightFrame.java
      @@ -35,6 +35,7 @@ import java.awt.Graphics;
       import java.awt.Graphics2D;
       import java.awt.MouseInfo;
       import java.awt.Point;
      +import java.awt.PointerInfo;
       import java.awt.Rectangle;
       import java.awt.Window;
       import java.awt.dnd.DragGestureEvent;
      @@ -470,7 +471,16 @@ public final class JLightweightFrame extends LightweightFrame implements RootPan
            * and could not be overridden.
            */
           private void updateClientCursor() {
      - Point p = MouseInfo.getPointerInfo().getLocation();
      + PointerInfo pointerInfo = MouseInfo.getPointerInfo();
      + if (pointerInfo == null) {
      + /*
      + * This can happen when JavaFX cannot decide
      + * which graphics device contains the current
      + * mouse position.
      + */
      + return;
      + }
      + Point p = pointerInfo.getLocation();
               SwingUtilities.convertPointFromScreen(p, this);
               Component target = SwingUtilities.getDeepestComponentAt(this, p.x, p.y);
               if (target != null) {


      Attachments

        Issue Links

          Activity

            People

              psadhukhan Prasanta Sadhukhan
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: