JDK-8056151 : Switching to GTK L&F on-the-fly leads to X Window System error RenderBadPicture
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8u20
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2014-08-23
  • Updated: 2015-09-29
  • Resolved: 2015-03-10
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 8 JDK 9
8u60Fixed 9 b56Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

FULL OS VERSION :
Linux feather 3.13.0-34-generic #60-Ubuntu SMP Wed Aug 13 15:45:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
JVM crash on Linux, terminated by X11, when invoking UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");

THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: Yes

THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
run my https://github.com/vorburger/CrashTestDummy - I've created a simple full example reliable reproducing it

I'm willing to help further debug this if required (provided I'm given due credit somewhere)

EXPECTED VERSUS ACTUAL BEHAVIOR :
JVM should "never* crash ;)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
    The program 'java' received an X Window System error.
    This probably reflects a bug in the program.
    The error was 'RenderBadPicture (invalid Picture parameter)'.
      (Details: serial 251 error_code 143 request_code 139 minor_code 6)
      (Note to programmers: normally, X errors are reported asynchronously;
       that is, you will receive the error a while after causing it.
       To debug your program, run it with the --sync command line
       option to change this behavior. You can then get a meaningful
       backtrace from your debugger if you break on the gdk_x_error() function.)

REPRODUCIBILITY :
This bug can be reproduced often.

---------- BEGIN SOURCE ----------
see https://github.com/vorburger/CrashTestDummy - I've created a simple full example reliable reproducing it
---------- END SOURCE ----------


Comments
Possible fix: diff -r c020e5199fa8 src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java --- a/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java +++ b/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java @@ -29,11 +29,10 @@ import static java.awt.RenderingHints.*; import java.awt.color.ColorSpace; import java.awt.image.*; import java.security.AccessController; -import java.security.PrivilegedAction; import sun.security.action.GetIntegerAction; import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection; import sun.java2d.opengl.OGLRenderQueue; -import java.lang.reflect.InvocationTargetException; +import sun.awt.X11.XToolkit; public abstract class UNIXToolkit extends SunToolkit { @@ -99,8 +98,12 @@ public abstract class UNIXToolkit extend public boolean loadGTK() { synchronized (GTK_LOCK) { if (nativeGTKLoaded == null) { - boolean success = load_gtk(); - nativeGTKLoaded = Boolean.valueOf(success); + XToolkit.awtLock(); + try { + nativeGTKLoaded = load_gtk(); + } finally { + XToolkit.awtUnlock(); + } } } return nativeGTKLoaded.booleanValue();
24-02-2015

The issue is reproducible only with XRender pipeline, it was enabled by default in 8b04 by JDK-7077423. java -Dsun.java2d.xrender=f SimpleTest runs without crash
24-02-2015

The issue is reproduced on the following simple sample: -------------- import java.awt.Color; import javax.swing.JWindow; import javax.swing.UIManager; public class SimpleTest { public static void main(String[] args) throws Exception { JWindow window = new JWindow(); window.setSize(465, 100 + 20); window.setBackground(new Color(0, 0, 0, 0)); window.setVisible(true); String laf = UIManager.getSystemLookAndFeelClassName(); System.out.println("Simple Test: UIManager.getSystemLookAndFeelClassName() = " + laf); UIManager.setLookAndFeel(laf); System.out.println("Simple Test: after non-crashed UIManager.setLookAndFeel()"); System.exit(0); } } --------------
09-10-2014

When invoking UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel") you should have gtk.GTLLookANDFeel jar file. By default it contains motif,windows and nimbus. Otherwise it works properly.
01-09-2014

To reproduce the issue run the following code from https://github.com/vorburger/CrashTestDummy -------------------------------- package crashtestdummy; import java.awt.Toolkit; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; /** * * @author Michael Vorburger <mike@vorburger.ch> */ public class CrashTestDummy { public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException { SplashScreen splash = new SplashScreen(Toolkit.getDefaultToolkit().getImage(SplashScreen.class.getResource("splash.png"))); splash.setVisible(true); String s = UIManager.getSystemLookAndFeelClassName(); System.out.println("UIManager.getSystemLookAndFeelClassName() = " + s); UIManager.setLookAndFeel(s); System.out.println("after non-crashed UIManager.setLookAndFeel()"); } } -------------------------------- package crashtestdummy; import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; public class SplashScreen extends JWindow { private static final long serialVersionUID = 1L; protected final ImageIcon icon; public SplashScreen(Image image) { this.icon = new ImageIcon(image); Container container = getContentPane(); container.setLayout(null); // Redraw the image to fix the alpha channel BufferedImage alphaImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB); Graphics2D g = alphaImage.createGraphics(); g.drawImage(image, 0, 0, icon.getIconWidth(), icon.getIconHeight(), null); g.dispose(); // Draw the image JButton background = new JButton(new ImageIcon(alphaImage)); background.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight()); background.setRolloverEnabled(true); background.setRolloverIcon(background.getIcon()); background.setSelectedIcon(background.getIcon()); background.setDisabledIcon(background.getIcon()); background.setPressedIcon(background.getIcon()); background.setFocusable(false); background.setContentAreaFilled(false); background.setBorderPainted(false); background.setOpaque(false); container.add(background); // Finalize setSize(icon.getIconWidth(), icon.getIconHeight() + 20); // try { // Not always supported... this.setBackground(new Color(0, 0, 0, 0)); // } catch (UnsupportedOperationException e) { // this.setBackground(new Color(0, 0, 0)); // } setLocationRelativeTo(null); } } -------------------------------- And use the splash.png from https://raw.githubusercontent.com/vorburger/CrashTestDummy/master/src/crashtestdummy/splash.png
27-08-2014

Not enough information to reproduce.
27-08-2014