简体   繁体   English

从IntelliJ运行JavaFX和Swing时的Segfault

[英]Segfault when running JavaFX and Swing from IntelliJ

When running the following minified example from IntelliJ 2016.1 Community edition, I always encounter a segmentation fault: 从IntelliJ 2016.1社区版运行以下缩小示例时,我总是遇到分段错误:

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: 环境如下:

  • Ubuntu 15.10 Ubuntu 15.10
  • openjdk-8 (1.8.0_u66 build 17) openjdk-8(1.8.0_u66 build 17)
  • openjfx-8 (8u60-b27-4) openjfx-8(8u60-b27-4)
  • IntelliJ 2016.1 Community Edition (build #IC-145.258) IntelliJ 2016.1社区版(build#IC-145.258)

The issue is not reproducible by running javac into java 通过将javac运行到java该问题无法重现
The problem also does not show when running through oraclejdk (1.8.0_u77-b03) 通过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 运行ulimit -c unlimited并重新启动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. 可以在IntelliJ外部重现该错误,如下所示。

public class Main {
    public static void main(String[] args) throws Exception {
        new Repro().main(new String[0]);
    }
}

running java -cp . Main 运行java -cp . Main java -cp . Main on Ubuntu 15.10 with java -cp . Main在Ubuntu 15.10上

openjdk version "1.8.0_66-internal" openjdk版“1.8.0_66-internal”
OpenJDK Runtime Environment (build 1.8.0_66-internal-b17) OpenJDK运行时环境(build 1.8.0_66-internal-b17)
OpenJDK 64-Bit Server VM (build 25.66-b17, mixed mode) OpenJDK 64位服务器VM(内置25.66-b17,混合模式)

produces the same fatal error. 产生同样的致命错误。 Whereas running java -cp . Repo 而运行java -cp . Repo java -cp . Repo does not fail. java -cp . Repo不会失败。

running java -cp . Main 运行java -cp . Main java -cp . Main on CentOS 7 with java -cp . Main在CentOS 7上

openjdk version "1.8.0_77" openjdk版本“1.8.0_77”
OpenJDK Runtime Environment (build 1.8.0_77-b03) OpenJDK运行时环境(版本1.8.0_77-b03)
OpenJDK 64-Bit Server VM (build 25.77-b03, mixed mode) OpenJDK 64位服务器VM(内置25.77-b03,混合模式)

opens the Swing JFrame and the JavaFX Pane. 打开Swing JFrame和JavaFX窗格。

Seems this issue is related to that specific OpenJDK version and the way the class Repo is called. 似乎这个问题与特定的OpenJDK版本以及调用类Repo的方式有关。

edit If you can't switch to another Java version there is a possible "workaround". 编辑如果您无法切换到另一个Java版本,则可能存在“解决方法”。 (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) 修改您的Repro.java如下所示,它不会在OpenJDK Runtime Environment (build 1.8.0_66-internal-b17)上失败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();
    ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM