JDK-8089584 : [SWT,Linux] FXCanvas will hang or crash on startup with swt-4.4 on Linux
  • Type: Bug
  • Component: javafx
  • Sub-Component: window-toolkit
  • Affected Version: 8u20,9
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • Submitted: 2015-01-29
  • Updated: 2016-11-21
  • Resolved: 2016-11-21
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 9
9Resolved
Related Reports
Blocks :  
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
Running a simple "HelloFXCanvas" program with swt4.4 on Linux will either hang (on OEL 7) or crash (on Ubuntu 14.04) on startup when libglass.so is loaded and initialized.

To reproduce this crash, compile and run the attached test program as follows:

1. Download the swt-4.4 bundle from:
http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.4-201406061215/swt-4.4-gtk-linux-x86_64.zip


2. Create a 'swt-4.4' directory, and unzip the bundle into that directory.


3. Compile the attached test program as follows:

A) Using a JDK with FX included:
javac -cp .:$JAVA_HOME/jre/lib/jfxswt.jar:$DOWNLOAD_DIR/swt-4.4/swt-debug.jar SimpleFXCanvas.java

-OR-

B) Using your own FX build and a JDK with jfxrt.jar removed:
javac -Xbootclasspath/a:$JAVAFX_HOME/rt/lib/ext/jfxrt.jar -cp .:$JAVAFX_HOME/rt/lib/jfxswt.jar:$DOWNLOAD_DIR/swt-4.4/swt-debug.jar SimpleFXCanvas.java


4. Run the test program as follows:

A) Using a JDK with FX included:
java -cp .:$JAVA_HOME/jre/lib/jfxswt.jar:$DOWNLOAD_DIR/swt-4.4/swt-debug.jar SimpleFXCanvas

-OR-

B) Using your own FX build and a JDK with jfxrt.jar removed:
java -Xbootclasspath/a:$JAVAFX_HOME/rt/lib/ext/jfxrt.jar -cp .:$JAVAFX_HOME/rt/lib/jfxswt.jar:$DOWNLOAD_DIR/swt-4.4/swt-debug.jar SimpleFXCanvas


BUG: The application will either hang or crash when libglass.so is loaded and initialized via System.load("libglass.so").

On Ubuntu 14.04 the JRE will crash. See the attached hs_err log.
On OEL 7 the JRE will hang. See the attached thread stack dump.
Comments
The auto-detection is covered by JDK-8157002, which is why I think that this issue is a duplicate of that one.
21-11-2016

Autodetection of SWT GTK version should be added to resolve the issue on JFX9.
21-11-2016

The root cause: GTK version cannot be detected automatically because Glass toolkit is initialized before SWT.
21-11-2016

Now that JEP 283 is done (see JDK-8145568) the rest of this is almost certainly a duplicate of JDK-8157002.
03-11-2016

[~ddhill] Can this issue be resolved as a duplicate of the JEP and/or JDK-8157002 ?
10-09-2016

Link to JEP for moving JavaFX to GTK3
11-11-2015

Since mixing GTK2 and GTK3 in the same application causes this problem, we might have to deliver two native libraries, one for GTK2 and one for GTK3, since Swing interop will still require GTK2.
10-11-2015

Raising priority to P2, we should address this for JDK 9 as it has an impact on JMC 6 testing and FC.
10-11-2015

Adding a dependency on the GTK migration bug.
12-02-2015

The root cause of the problem is that JFX on Linux uses Gtk2.0 and swt-4.4 by default uses Gtk3.0. Mixing these libraries causes symbol issues and the crash. Using: export SWT_GTK3=0 causes SWT to fall back to Gtk2.0 allowing it to coexist with JFX. There are a lot of issues with migrating JFX to use Gtk 3.0, so these will be addressed in a different Jira.
12-02-2015

WORKAROUND ! export SWT_GTK3=0 prior to running the javafx application solves the issue on Linux. Now to understand why...
12-02-2015

GDB sees the problem here: 0x00007fff8f526e1f in gdk_display_open () from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 (gdb) bt #0 0x00007fff8f526e1f in gdk_display_open () from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 #1 0x00007fff8f4f7f4d in gdk_display_open_default_libgtk_only () from /usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0 #2 0x00007fff8f8b72d4 in gtk_init_check () from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 #3 0x00007fff8f8b72f9 in gtk_init () from /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0 #4 0x00007fffa418d6bf in JNI_OnLoad () from /home/ddhill/lsb/8u/graphics/rt/build/sdk/rt/lib/amd64/libglass.so #5 0x00007ffff5b20617 in Java_java_lang_ClassLoader_00024NativeLibrary_load () from /opt/jdk1.8.0_20/jre/lib/amd64/libjava.so #6 0x00007fffe10134d4 in ?? () #7 0x00000000e0e05b08 in ?? () #8 0x00007fffe100798d in ?? () #9 0x00007ffff7fd5138 in ?? () #10 0x00007fffe100798d in ?? () #11 0x00007ffff7fd50e0 in ?? () #12 0x0000000000000000 in ?? ()
11-02-2015

Looks like I can reproduce it on Linux. build with gradle -PCOMPILE_SWT=true compile with: javac -cp $HOME/lsb/8u/graphics/rt/build/sdk/rt/lib/ext/jfxrt.jar:$HOME/lsb/8u/graphics/rt/build/sdk/rt/lib/jfxswt.jar:swt.jar SimpleFXCanvas.java run with: java -cp $HOME/lsb/8u/graphics/rt/build/sdk/rt/lib/ext/jfxrt.jar:$HOME/lsb/8u/graphics/rt/build/sdk/rt/lib/jfxswt.jar:swt.jar:. SimpleFXCanvas
11-02-2015

Target to 9 but we need to pull this into 8u60 if possible.
29-01-2015