JDK-6714678 : IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs process on Linux
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u7,6u10,6u17
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,linux_ubuntu,solaris_2.5.1
  • CPU: x86,sparc
  • Submitted: 2008-06-14
  • Updated: 2017-05-16
  • Resolved: 2008-07-28
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
6u10Fixed 7Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
Given the java class below, debug that source code with Netbeans (I used 6.1), Eclipse or JDeveloper on Linux using JDK 6 update 7 (it works fine with jdk 1.5.0) and put a breakpoint on the line i++, debug the source file and cause the debugger to trigger the breakpoint.   Note the entire Linux (I use GNome) Window manager is frozen, both keyboard and mouse don't respond anymore.

package client;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Frame1 extends JFrame implements ItemListener {
  private JComboBox jComboBox1 = new JComboBox(new String[] { "Apples", "Oranges", "Mangoes"});

  public Frame1() {
    try {
      jbInit();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    this.getContentPane().setLayout( null );
    this.setSize( new Dimension(400, 300) );
    jComboBox1.setBounds(new Rectangle(45, 25, 235, 25));
    jComboBox1.addItemListener(this);
    this.getContentPane().add(jComboBox1, null);
    this.setVisible(true);
  }

  public void itemStateChanged(ItemEvent e) {
    System.out.println("Entering ItemStateChanged");
    int x = 1;
    x++;      // put a breakpoint on that line and it will freeze
    System.out.println("Exiting ItemStateChanged");
  }
  public static void  main(String[] s) {
    new Frame1();
  }
}

Comments
EVALUATION The only reasonable solution to this problem is introducing the system property sun.awt.disablegrab which, if passed as the boolean value of true, effectively disables acquiring grabs on X11 platforms. If the user wishes to debug an application and sets a breakpoint in an event handler that gets fired while a popup window is opened (like a combobox popup), the user must specify this system property before debugging the application as follows: java -Dsun.awt.disablegrab=true ...<other_options>... All known IDEs allow specifying the user-supplied command line options to the java command, making this solution easily adoptable. For instance, in Netbeans open the properties of the project, go to the Run section and type the text "-Dsun.awt.disablegrab=true" (w/o the quotes) into the VM Options editbox. Of course, the project must be configured to run with a JRE having the suggested fix in place.
26-06-2008

SUGGESTED FIX --- old/src/solaris/classes/sun/awt/X11/XBaseWindow.java 2008-06-27 13:01:13.000000000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XBaseWindow.java 2008-06-27 13:01:13.000000000 +0400 @@ -854,28 +854,35 @@ | EnterWindowMask | LeaveWindowMask | PointerMotionMask | ButtonMotionMask); final int ownerEvents = 1; - - int ptrGrab = XlibWrapper.XGrabPointer(XToolkit.getDisplay(), - getContentWindow(), ownerEvents, eventMask, GrabModeAsync, - GrabModeAsync, None, (XWM.isMotif() ? XToolkit.arrowCursor : None), - CurrentTime); - // Check grab results to be consistent with X server grab - if (ptrGrab != GrabSuccess) { - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); - XAwtState.setGrabWindow(null); - grabLog.fine(" Grab Failure - mouse"); - return false; - } - - int keyGrab = XlibWrapper.XGrabKeyboard(XToolkit.getDisplay(), - getContentWindow(), ownerEvents, GrabModeAsync, GrabModeAsync, - CurrentTime); - if (keyGrab != GrabSuccess) { - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); - XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), CurrentTime); - XAwtState.setGrabWindow(null); - grabLog.fine(" Grab Failure - keyboard"); - return false; + + //6714678: IDE (Netbeans, Eclipse, JDeveloper) Debugger hangs + //process on Linux + //The user must pass the sun.awt.disableGrab property to disable + //taking grabs. This prevents hanging of the GUI when a breakpoint + //is hit while a popup window taking the grab is open. + if (!XToolkit.getSunAwtDisableGrab()) { + int ptrGrab = XlibWrapper.XGrabPointer(XToolkit.getDisplay(), + getContentWindow(), ownerEvents, eventMask, GrabModeAsync, + GrabModeAsync, None, (XWM.isMotif() ? XToolkit.arrowCursor : None), + CurrentTime); + // Check grab results to be consistent with X server grab + if (ptrGrab != GrabSuccess) { + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); + XAwtState.setGrabWindow(null); + grabLog.fine(" Grab Failure - mouse"); + return false; + } + + int keyGrab = XlibWrapper.XGrabKeyboard(XToolkit.getDisplay(), + getContentWindow(), ownerEvents, GrabModeAsync, GrabModeAsync, + CurrentTime); + if (keyGrab != GrabSuccess) { + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); + XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), CurrentTime); + XAwtState.setGrabWindow(null); + grabLog.fine(" Grab Failure - keyboard"); + return false; + } } if (prevGrabWindow != null) { prevGrabWindow.ungrabInputImpl(); @@ -895,8 +902,10 @@ grabLog.log(Level.FINE, "UnGrab input on {0}", new Object[] {grabWindow}); if (grabWindow != null) { grabWindow.ungrabInputImpl(); - XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); - XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), CurrentTime); + if (!XToolkit.getSunAwtDisableGrab()) { + XlibWrapper.XUngrabPointer(XToolkit.getDisplay(), CurrentTime); + XlibWrapper.XUngrabKeyboard(XToolkit.getDisplay(), CurrentTime); + } XAwtState.setGrabWindow(null); // we need to call XFlush() here to force ungrab // see 6384219 for details --- old/src/solaris/classes/sun/awt/X11/XToolkit.java 2008-06-27 13:01:14.000000000 +0400 +++ new/src/solaris/classes/sun/awt/X11/XToolkit.java 2008-06-27 13:01:14.000000000 +0400 @@ -30,6 +30,7 @@ import sun.font.FontManager; import sun.misc.PerformanceLogger; import sun.print.PrintJob2D; +import sun.security.action.GetBooleanAction; import java.lang.reflect.*; public class XToolkit extends UNIXToolkit implements Runnable, XConstants { @@ -2151,5 +2152,13 @@ new AwtGraphicsConfigData(((X11GraphicsConfig)gc).getAData()); return 0 != graphicsConfigData.get_isTranslucencySupported(); } + + /** + * Returns the value of "sun.awt.disableGrab" property. Default + * value is {@code false}. + */ + public static boolean getSunAwtDisableGrab() { + return AccessController.doPrivileged(new GetBooleanAction("sun.awt.disableGrab")); + } }
26-06-2008

EVALUATION This is likely to be a duplicate of classes_awt bug 6384219.
14-06-2008

WORK AROUND No workaround. I would love to have one.
14-06-2008