When running the following minified example from IntelliJ 2016.1 Community edition, I always encounter a segmentation fault:
import javax.swing.*;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class Repro extends Application {
public static void main(String[] args) {
JFrame swingFrame = new JFrame();
swingFrame.setTitle("Repro start");
swingFrame.setSize(200, 350);
swingFrame.setVisible(true);
Application.launch(args);
}
@Override
public void start(Stage stage) throws Exception {
Pane root = new Pane();
root.setMinHeight(200);
root.setMinWidth(350);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
}
The environment is as follows:
The issue is not reproducible by running javac
into java
The problem also does not show when running through oraclejdk (1.8.0_u77-b03)
For reference the "output" of the program is as follows:
Prism-ES2 Error : GL_VERSION (major.minor) = 1.4
Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" Exception in thread "JavaFX Application Thread" #
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (safepoint.cpp:712), pid=16937, tid=140197878814464
# fatal error: Illegal threadstate encountered: 6
#
# JRE version: OpenJDK Runtime Environment (8.0_66-b17) (build 1.8.0_66-internal-b17)
# Java VM: OpenJDK 64-Bit Server VM (25.66-b17 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/vogel612/.../hs_err_pid16937.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
Process finished with exit code 134
The problem persists after running ulimit -c unlimited
and restarting IntelliJ
As requested, the error log for one such execution is available at this gist.
How can I fix this behaviour?
The error can be reproduced outside IntelliJ as follow.
public class Main {
public static void main(String[] args) throws Exception {
new Repro().main(new String[0]);
}
}
running java -cp . Main
java -cp . Main
on Ubuntu 15.10 with
openjdk version "1.8.0_66-internal"
OpenJDK Runtime Environment (build 1.8.0_66-internal-b17)
OpenJDK 64-Bit Server VM (build 25.66-b17, mixed mode)
produces the same fatal error. Whereas running java -cp . Repo
java -cp . Repo
does not fail.
running java -cp . Main
java -cp . Main
on CentOS 7 with
openjdk version "1.8.0_77"
OpenJDK Runtime Environment (build 1.8.0_77-b03)
OpenJDK 64-Bit Server VM (build 25.77-b03, mixed mode)
opens the Swing JFrame and the JavaFX Pane.
Seems this issue is related to that specific OpenJDK version and the way the class Repo
is called.
edit If you can't switch to another Java version there is a possible "workaround". (based on this post )
Amend your Repro.java
as below and it will not fail on OpenJDK Runtime Environment (build 1.8.0_66-internal-b17)
public static void main(String[] args) throws Exception {
new JFXPanel(); // the "workaround" to initialize the toolkit
JFrame swingFrame = new JFrame();
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.