Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8054661

JVM crashes when exit the application

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 8u11
    • hotspot
    • x86
    • windows_7

      FULL PRODUCT VERSION :
      eclipse sdk

      ADDITIONAL OS VERSION INFORMATION :
      windows-7 32 bit

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      nothing

      A DESCRIPTION OF THE PROBLEM :
      Bug #1:
      -------
      Bug Name: JVM crashes on exit

      Comments From Christian:
      ------------------------
      Each time the IDE is closed, a dialog box with the following content is displayed (as if the JVM crashed):

      JVM terminated. Exit code=255
      /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/jre/bin/java
      -jar /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
      -os linux
      -ws gtk
      -arch x86_64
      -showsplash
      -launcher /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/launcher
      -name Launcher
      --launcher.library /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20131025-1931/eclipse_1601.so
      -startup /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
      --launcher.overrideVmargs
      -exitdata 119d800a
      -vm /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/jre/bin/java
      -vmargs
      -jar /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar

      This might be related to calling System.exit which is not a good way to close a Java application.
      I think it is better to investigate what is blocking JVM in the first place (most likely it is blocked by reading AMPL input from a pipe) and fix it instead of using
      System.exit which can have potentially dangerous side-effects in addition to annoying dialogs.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      not cause an issue while exit the application
      ACTUAL -
      close the application when press EXIT

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      JVM terminated. Exit code=255
      /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/jre/bin/java
      -jar /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
      -os linux
      -ws gtk
      -arch x86_64
      -showsplash
      -launcher /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/launcher
      -name Launcher
      --launcher.library /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20131025-1931/eclipse_1601.so
      -startup /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
      --launcher.overrideVmargs
      -exitdata 119d800a
      -vm /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/jre/bin/java
      -vmargs
      -jar /home/viz/workspace/ampl-ide/ampl-ide/site/target/products/com.amplide.rcp.liteproduct/linux/gtk/x86_64/amplide/plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar

      This might be related to calling System.exit which is not a good way to close a Java application.
      I think it is better to investigate what is blocking JVM in the first place (most likely it is blocked by reading AMPL input from a pipe) and fix it instead of using
      System.exit which can have potentially dangerous side-effects in addition to annoying dialogs

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package com.amplide.launching;

      import static com.amplide.launching.Attributes.*;

      import java.io.File;
      import java.io.IOException;
      import java.text.MessageFormat;
      import java.util.Collections;
      import java.util.List;

      import org.eclipse.core.resources.IProject;
      import org.eclipse.core.resources.IWorkspaceRoot;
      import org.eclipse.core.resources.ResourcesPlugin;
      import org.eclipse.core.runtime.CoreException;
      import org.eclipse.core.runtime.IProgressMonitor;
      import org.eclipse.core.runtime.NullProgressMonitor;
      import org.eclipse.debug.core.ILaunch;
      import org.eclipse.debug.core.ILaunchConfiguration;
      import org.eclipse.debug.core.model.IProcess;
      import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;

      import org.eclipse.ui.console.IConsole;
      import org.eclipse.ui.console.IPatternMatchListener;
      import org.eclipse.ui.console.PatternMatchEvent;
      import org.eclipse.ui.console.TextConsole;

      import sampl.Util;

      import com.amplide.Plugin;

      public class LaunchDelegate extends AbstractJavaLaunchConfigurationDelegate {

          public static final String AMPL_ID = "com.amplide.launching.ampl";
          
          // Listens to the document change events and, once the ampl prompt appears,
          // refreshes the solution view.
          private static class PromptListener implements IPatternMatchListener {
              private TextConsole console;
              private File solutionFile;

              PromptListener(File solutionFile) {
                  this.solutionFile = solutionFile;
              }
              
              @Override
              public void connect(TextConsole console) {
                  this.console = console;
              }

              @Override
              public void disconnect() {
                  console = null;
              }

              @Override
              public void matchFound(PatternMatchEvent event) {
                  if (console == null)
                      return;
                  
                  console.removePatternMatchListener(this);
                  
              }

              @Override
              public String getPattern() {
                  return "ampl: ";
              }

              @Override
              public int getCompilerFlags() {
                  return 0;
              }

              @Override
              public String getLineQualifier() {
                  return null;
              }
          }

          private static File getWorkingDir(List<?> projectNames) {
              if (projectNames.isEmpty())
                  return null;
              IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
              IProject project = root.getProject((String)projectNames.get(0));
              return new File(root.getRawLocation().toString(),
                      project.getFullPath().toString());
          }
          
          @Override
          public void launch(ILaunchConfiguration configuration, String mode,
                  ILaunch launch, IProgressMonitor monitor) throws CoreException {
              Plugin plugin = Plugin.getDefault();

              if (monitor == null)
                  monitor = new NullProgressMonitor();
              try {
                  monitor.beginTask(MessageFormat.format("{0}...",
                          configuration.getName()), 2);
                  if (monitor.isCanceled())
                      return;
                  
                  List<?> projectNames = configuration.getAttribute(PROJECT_NAMES,
                          Collections.EMPTY_LIST);
                  
                  File workingDir = getWorkingDir(projectNames);
                  if (workingDir == null)
                      return;
                  
                  File includeDir = new File(plugin.pluginDir(), "include");
                  
                  StringBuilder command = new StringBuilder();
                  command.append("print;\n");
                  command.append("reset;\n");
                  command.append("option ampl_include " +
                   Util.quote(".\n" + includeDir.getPath()) + ";\n");
                  String prelaunchFilename = "prelaunch.ampl";
                  if (new File(includeDir, prelaunchFilename).exists()) {
                      command.append(
                              "model " + Util.quote(prelaunchFilename) + ";\n");
                  }
                  
                  // Done the preparation - 1 unit of work.
                  monitor.worked(1);

                  IProcess process = plugin.amplProcess();
                  
                  File solutionFile = null;
                  List<?> paths = configuration.getAttribute(RELATIVE_PATHS,
                          Collections.EMPTY_LIST);
                  
                      String redirection = null;
                      if (new File("/dev/null").exists())
                          redirection = "> /dev/null";
                      else if (new File("NUL").exists())
                          redirection = "> NUL";
                      command.append("cd " + Util.quote(workingDir.toString()) +
                              " " + redirection + ";");
                      
                  for (Object obj: paths) {
                      String path = obj.toString();
                      if (path.toLowerCase().endsWith(".dat"))
                          command.append("data");
                      else command.append("model");
                      command.append(" ").append(Util.quote(path));
                      command.append(";\n");
                  }
                  if (configuration.getAttribute(AUTO_SOLVE, false)) {
                      String ext = ".sol";
                      solutionFile = File.createTempFile("ampl", ext);
                      String solutionPath = solutionFile.getAbsolutePath();
                      
                          command.append("solve;\n");
                          command.append("param __sol_filename symbolic = '");
                          command.append(solutionPath);
                          command.append("';");
                          command.append("model writesol.ampl;");
                      
                  }
                  command.append("option prompt1 'ampl: ';\n");
                  IConsole console = ((AMPLProcess) process).getConsole();
                  if (console instanceof TextConsole) {
                      TextConsole textConsole = (TextConsole)console;
                      textConsole.addPatternMatchListener(
                              new PromptListener(solutionFile));
                  }
                  process.getStreamsProxy().write(command.toString());
                  monitor.worked(1);
              } catch (IOException e) {
                  throw new RuntimeException(e);
              } finally {
                  monitor.done();
              }
          }
      }

      ---------- END SOURCE ----------

      SUPPORT :
      YES

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: