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

Program hang when invoke printStackTrace() of Throwable in 2nd jvm

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.4.2
    • hotspot
    • x86
    • windows_2000

      Name: gm110360 Date: 05/12/2004


      FULL PRODUCT VERSION :
      java version "1.4.2_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
      Java HotSpot(TM) Client VM (build 1.4.2_04-b05, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows 2000 [Version 5.00.2195]

      A DESCRIPTION OF THE PROBLEM :
        Program hang when invoke the printStackTrace() of Throwable in the 2nd JVM, which is brought by the code akin to Runtime.getRuntime().exec("java SubApp");

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Make 3 files of the submitted code/script, namely MainApp.java, SubApp.java, launchSubApp.bat.
      2. Compile the files
      3. java -cp . MainApp
      4. Click "Launch SubApp" button.
      5. Click "click me" button.


      ACTUAL -
        Program hang.

      [my comments]
      by having examined the log file (log.txt in the same directory), it can be confirmed that the hang is caused by execute the statement: e.printStackTrace(). which may due to consecutive invoking of System.err.println().

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      1. MainApp.java

      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;

      public class MainApp extends JFrame
      {
      public MainApp() {
      setTitle("MainApp");
      JButton button = new JButton("Launch SubApp");
      button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      try {
      Runtime.getRuntime().exec("launchSubApp.bat");
      } catch (Exception exp) {
      exp.printStackTrace();
      }
      }
      });
      getContentPane().add(button, BorderLayout.CENTER);
      setSize(200, 50);
      setVisible(true);
      }

      public static void main(String[] args) {
      new MainApp();
      }
      }

      2. SubApp.java

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;

      public class SubApp extends JFrame {
      public SubApp() {
      setTitle("SubApp");
      JButton button = new JButton("Click me");
      button.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      try {
      throw new Exception("Exception occurs!");
      } catch (Exception exp) {
      System.out.println("In catach block, before invoke printStackTrace()");
      exp.printStackTrace();
      // the system will also hang after execute System.err.println() for 9 times
      // if replace exp.prinStackTrace() with below statements.
      // for (int i = 0; i < 20; i++) {
      // System.err.println("i = " + i);
      // System.out.println("i = " + i);
      // }
      System.out.println("Done.");
      }
      }
      });
      getContentPane().add(button, BorderLayout.CENTER);
      setSize(200,100);
      setVisible(true);
      }

      public static void main(String args[]) {
      new SubApp();
      }
      }

      3. launchSubApp.bat

      java SubApp > log.txt
      ---------- END SOURCE ----------
      (Incident Review ID: 265056)
      ======================================================================
      ###@###.### 10/5/04 22:31 GMT

            ksrini Kumar Srinivasan
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: