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

Frame disposal on a repeated loop causes crashes.

XMLWordPrintable

    • b01
    • sparc
    • solaris_2.5.1


      chosho.kyo@japan 1998-11-12
      (1) Working environments
      OS : Solaris2.5.1J, 2.6J
      JRE : JRE1.1.6fcs

      (2) Phenomenon
          Frame disposal on a repeated loop causes crashes.
          Running the following source Frame1.java can see the crash.
          Thread dump message and stack trace info are also attached below
          for analysis.
          
      (3) Reproducible Source
      //------------Frame1.java---------

      import java.awt.*;
      import java.awt.event.*;
      import java.util.*;

      public class Frame1 extends Frame {
          Button button1 = new Button();
          CheckboxGroup checkboxGroup1 = new CheckboxGroup();
          Checkbox checkbox1 = new Checkbox();
          Checkbox checkbox2 = new Checkbox();
          Choice choice1 = new Choice();
          Label label1 = new Label();
          List list1 = new List();
          MenuBar menuBar1 = new MenuBar();
          PopupMenu popupMenu1 = new PopupMenu("popup");
          MenuItem menuItem2 = new MenuItem("menuItem2");
          Panel panel1 = new Panel();
          Scrollbar scrollbar1 = new Scrollbar();
          TextArea textArea1 = new TextArea();
          TextField textField1 = new TextField();
          Label label2 = new Label();
          ScrollPane scrollPane1 = new ScrollPane();
          Panel panel2 = new Panel();
          Button button2 = new Button();
          Button button3 = new Button();
          Menu menu1 = new Menu("menu1");
          MenuItem menuItem1 = new MenuItem("menuItem1");
          Canvas canvas1 = new Canvas();
          BorderLayout borderLayout1 = new BorderLayout();
          Button button4 = new Button();


          public Frame1() {
              try {
                  jbInit();
              }
              catch (Exception e) {
                  e.printStackTrace();
              }
          }

          public static void main(String[] args) {
              Frame1 frame11 = new Frame1();
              frame11.setVisible(true);
          }

          private void jbInit() throws Exception {
              this.setSize(new Dimension(464, 499));
              button1.setBounds(new Rectangle(23, 85, 49, 45));
              button1.setLabel("open");
              button1.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      button1_actionPerformed(e);
                  }
              });
              checkbox1.setBounds(new Rectangle(24, 145, 88, 23));
              checkbox1.setLabel("checkbox1");
              checkbox1.setCheckboxGroup(checkboxGroup1);
              checkbox1.addItemListener(new java.awt.event.ItemListener() {
                  public void itemStateChanged(ItemEvent e) {
                      checkbox1_itemStateChanged(e);
                  }
              });
              checkbox2.setBounds(new Rectangle(128, 146, 88, 23));
              checkbox2.setLabel("checkbox2");
              checkbox2.setCheckboxGroup(checkboxGroup1);
              checkboxGroup1.setSelectedCheckbox(checkbox1);
              choice1.setBounds(new Rectangle(32, 190, 154, 25));
              choice1.addItemListener(new java.awt.event.ItemListener() {
                  public void itemStateChanged(ItemEvent e) {
                      choice1_itemStateChanged(e);
                  }
              });
              menuItem2.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      menuItem2_actionPerformed(e);
                  }
              });
              scrollPane1.setBounds(new Rectangle(319, 352, 111, 77));
              panel2.setLayout(borderLayout1);
              button2.setBounds(new Rectangle(80, 86, 48, 45));
              button2.setLabel("close");
              button3.setBounds(new Rectangle(132, 85, 102, 47));
              button3.setLabel("System.gc()");
              button4.setBounds(new Rectangle(240, 87, 45, 44));
              button4.setLabel("auto");
              button4.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      button4_actionPerformed(e);
                  }
              });
              canvas1.addMouseListener(new java.awt.event.MouseAdapter() {
                  public void mouseClicked(MouseEvent e) {
                      canvas1_mouseClicked(e);
                  }
              });
              menuItem1.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      menuItem1_actionPerformed(e);
                  }
              });
              button3.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      button3_actionPerformed(e);
                  }
              });
              button2.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      button2_actionPerformed(e);
                  }
              });
              choice1.add("choice 1");
              choice1.add("choice 2");
              label1.setBounds(new Rectangle(33, 248, 162, 43));
              label1.setText("label1");
              list1.setBounds(new Rectangle(248, 245, 112, 68));
              list1.addItemListener(new java.awt.event.ItemListener() {
                  public void itemStateChanged(ItemEvent e) {
                      list1_itemStateChanged(e);
                  }
              });
              panel1.setBounds(new Rectangle(32, 364, 137, 64));
              scrollbar1.setBounds(new Rectangle(231, 357, 20, 76));
              scrollbar1.addAdjustmentListener(new java.awt.event.AdjustmentListener() {
                  public void adjustmentValueChanged(AdjustmentEvent e) {
                      scrollbar1_adjustmentValueChanged(e);
                  }
              });
              textArea1.setBounds(new Rectangle(307, 87, 124, 110));
              textArea1.setText("textArea1");
              textField1.setBounds(new Rectangle(33, 302, 155, 27));
              textField1.setText("textField1");
              textField1.addActionListener(new java.awt.event.ActionListener() {
                  public void actionPerformed(ActionEvent e) {
                      textField1_actionPerformed(e);
                  }
              });
              label2.setText("this is panel");
              this.setLayout(null);
              this.add(button1, null);
              this.add(checkbox1, null);
              this.add(checkbox2, null);
              this.add(choice1, null);
              this.add(label1, null);
              list1.add("list1");
              list1.add("list2");
              this.add(list1, null);
              this.add(panel1, null);
              panel1.add(label2, null);
              this.add(scrollbar1, null);
              this.add(textArea1, null);
              this.add(textField1, null);
              this.add(scrollPane1, null);
              scrollPane1.add(panel2, null);
              panel2.add(canvas1);
              this.add(button2, null);
              this.add(button3, null);
              this.add(button4, null);
              menu1.add(menuItem1);
              menuBar1.add(menu1);
              this.setMenuBar(menuBar1);
              this.add(popupMenu1);
              popupMenu1.add(menuItem2);
          }
          public void finalize(){
              //System.out.println("finalize called");

          }

          void button1_actionPerformed(ActionEvent e) {
              Frame1 frame1 = new Frame1();
              frame1.setVisible(true);

          }

          void button2_actionPerformed(ActionEvent e) {
              this.dispose();
              System.gc();
          }

          void button3_actionPerformed(ActionEvent e) {
              System.gc();
          }

          void menuItem1_actionPerformed(ActionEvent e) {
              System.out.println("menuItem1_actionPerformed");
          }

          void canvas1_mouseClicked(MouseEvent e) {
              popupMenu1.show(canvas1, e.getX(), e.getY());
          }

          void menuItem2_actionPerformed(ActionEvent e) {
              System.out.println("menuItem2_actionPerformed");
          }

          void choice1_itemStateChanged(ItemEvent e) {
              System.out.println("choice1_itemStateChanged");
          }

          void checkbox1_itemStateChanged(ItemEvent e) {
              System.out.println("checkbox1_itemStateChanged");
          }

          void list1_itemStateChanged(ItemEvent e) {
              System.out.println("list1_itemStateChanged");
          }

          void textField1_actionPerformed(ActionEvent e) {
              System.out.println("textField1_actionPerformed");
          }

          void scrollbar1_adjustmentValueChanged(AdjustmentEvent e) {
              System.out.println("scrollbar1_adjustmentValueChanged");
          }

          void button4_actionPerformed(ActionEvent e) {

              new AutoExec();
          }
      }

      class AutoExec extends Thread{
          public AutoExec(){
              this.start();
          }
          public void run(){
              for(int i = 0; i < 2002; i++){
                  Frame1 f = new Frame1();
                  f.setVisible(true);
                  f.dispose();
                  System.gc();
                  if(i % 200 == 0){
                      System.out.println(Integer.toString(i+1));
                  }

              }
          }

      }

      //-----------------Frame1.java End-----------------------

      (4) Thread Dump & Stack Trace
      -----------------Thread Dump Begin-------------------------------------------
      SIGSEGV 11* segmentation violation
          si_signo [11]: SIGSEGV 11* segmentation violation
          si_errno [0]: Error 0
          si_code [1]: SEGV_MAPERR [addr: 0x15]

              stackbase=EF0D2000, stackpointer=EF0D1668

      Full thread dump:
          "Thread-4" (TID:0xee307690, sys_thread_t:0xef041db8, state:MW) prio=5
              sun.awt.motif.MFramePeer.setMenuBar(MFramePeer.java:112)
              java.awt.Frame.remove(Frame.java:349)
              java.awt.Frame.dispose(Frame.java:378)
              AutoExec.run(Frame1.java:232)
          "AWT-Finalizer" (TID:0xee307b20, sys_thread_t:0xef071db8, state:CW) prio=9
              java.lang.Object.wait(Object.java)
              sun.awt.AWTFinalizer.run(AWTFinalizer.java:48)
          "Screen Updater" (TID:0xee3076e8, sys_thread_t:0xef0a1db8, state:CW) prio=4
              java.lang.Object.wait(Object.java)
              sun.awt.ScreenUpdater.nextEntry(ScreenUpdater.java:78)
              sun.awt.ScreenUpdater.run(ScreenUpdater.java:98)
          "AWT-Motif" (TID:0xee305908, sys_thread_t:0xef0d1db8, state:R) prio=5 *current thread*
              java.lang.Thread.run(Thread.java)
          "AWT-Input" (TID:0xee305928, sys_thread_t:0xef101db8, state:CW) prio=5
          "AWT-EventQueue-0" (TID:0xee305940, sys_thread_t:0xef131db8, state:MW) prio=5
              sun.awt.motif.MComponentPeer.handleEvent(MComponentPeer.java:185)
              java.awt.Component.dispatchEventImpl(Component.java:1834)
              java.awt.Component.dispatchEvent(Component.java:1708)
              java.awt.EventDispatchThread.run(EventDispatchThread.java:81)
          "Finalizer thread" (TID:0xee300208, sys_thread_t:0xef341db8, state:CW) prio=1
          "Async Garbage Collector" (TID:0xee300250, sys_thread_t:0xef371db8, state:CW) prio=1
          "Idle thread" (TID:0xee300298, sys_thread_t:0xef471db8, state:R) prio=0
          "Clock" (TID:0xee300088, sys_thread_t:0xef541db8, state:CW) prio=12
          "main" (TID:0xee3000b0, sys_thread_t:0x38c00, state:CW) prio=5
      Monitor Cache Dump:
          java.lang.Object@EE303FA0/EE34D9F0: owner "Thread-4" (0xef041db8, 2 entries)
              Waiting to enter:
                  "AWT-EventQueue-0" (0xef131db8)
          sun.awt.motif.MToolkit@EE305708/EE352EF8: owner "AWT-Motif" (0xef0d1db8, 1 entry)
              Waiting to enter:
                  "Thread-4" (0xef041db8)
              Waiting to be notified:
                  "AWT-Input" (0xef101db8)
          sun.awt.AWTFinalizer@EE307B20/EE35B0F8: <unowned>
              Waiting to be notified:
                  "AWT-Finalizer" (0xef071db8)
          <unknown key> (0xef371db8): <unowned>
              Waiting to be notified:
                  "Async Garbage Collector" (0xef371db8)
          sun.awt.ScreenUpdater@EE3076E8/EE35AD38: <unowned>
              Waiting to be notified:
                  "Screen Updater" (0xef0a1db8)
      Registered Monitor Dump:
          Thread queue lock: <unowned>
              Waiting to be notified:
                  "main" (0x38c00)
          Name and type hash table lock: <unowned>
          String intern lock: <unowned>
          JNI pinning lock: <unowned>
          JNI global reference lock: <unowned>
          BinClass lock: <unowned>
          Class loading lock: <unowned>
          Java stack lock: <unowned>
          Code rewrite lock: <unowned>
          Heap lock: <unowned>
          Has finalization queue lock: <unowned>
          Finalize me queue lock: <unowned>
              Waiting to be notified:
                  "Finalizer thread" (0xef341db8)
          Monitor IO lock: <unowned>
          Child death monitor: <unowned>
          Event monitor: <unowned>
          I/O monitor: <unowned>
          Alarm monitor: <unowned>
              Waiting to be notified:
                  "Clock" (0xef541db8)
          Sbrk lock: <unowned>
          Monitor registry: owner "AWT-Motif" (0xef0d1db8, 1 entry)
      Thread Alarm Q:
          sys_thread_t 0xef371db8 [Timeout in 480 ms]
      Abort (core dumped)
      -----------------Thread Dump End-------------------------------------------

      ------------------Stack Trace Begin---------------------------------------
      =>[1] _lwp_kill(0x0, 0x6, 0x7d, 0xef0d1668, 0xef40df88, 0x0), at 0xef3b952c
        [2] sysAbort(0x0, 0xef0d2000, 0xef0d0f80, 0xb, 0x0, 0x0), at 0xef70c924
        ---- called from signal handler with signal 11 (SIGSEGV) ------
        [3] XtGetValues(), at 0xef1b2748
        [4] XtVaGetValues(0x19fb30, 0xef1f016c, 0x0, 0x241f78, 0x0, 0xef0d141c), at 0xef1daa94
        [5] setMbAndWwHeightAndOffsets(0xef1df2f5, 0x2190d8, 0xef1df184, 0xef1df1f2, 0xee30ef20, 0x6c), at 0xef232c48
        [6] reshape(0xee30ef20, 0x2190d8, 0x0, 0x0, 0x1d0, 0x1), at 0xef234738
        [7] shellEH(0xfffffffe, 0x0, 0xef0d1744, 0x5, 0xee391af0, 0x2190d8), at 0xef2333e4
        [8] XtDispatchEventToWidget(0x0, 0xef0d1744, 0xef0d15f4, 0xef0d1604, 0x0, 0x2), at 0xef1ace98
        [9] _XtDefaultDispatcher(0xef0d1744, 0x0, 0x15, 0xee3d4, 0x0, 0x22f6f8), at 0xef1ad9b4
        [10] XtDispatchEvent(0xef0d1744, 0x0, 0xef1ad7f4, 0xef1f016c, 0x0, 0x1), at 0xef1ade3c
        [11] XtAppProcessEvent(0xf1140, 0x0, 0xef228b70, 0x1, 0xef1f016c, 0x0), at 0xef1bbc4c
        [12] awt_MToolkit_loop(0x972b0, 0xef26cc94, 0xef2600e8, 0xef264684, 0xef26cc14, 0x1), at 0xef228dac
        [13] sun_awt_motif_MToolkit_run(0xef26cc94, 0xef2600f8, 0xef736808, 0x10, 0x2, 0x49), at 0xef228e6c
        [14] Java_sun_awt_motif_MToolkit_run_stub(0x109298, 0xef0d1c6c, 0x0, 0x0, 0x58b70, 0x0), at 0xef24a934
        [15] invokeNativeMethod(0x109270, 0xfa9f0, 0x109298, 0xef0d1c6c, 0xef6d5ae4, 0xee3000b8), at 0xef6d5f7c
        [16] finish_invokevirtual(0x5a913, 0xef0d1c6c, 0x109298, 0x10926c, 0x587a0, 0x109270), at 0xef7162e0
        [17] do_execute_java_method_vararg(0xef0d1c6c, 0xef733c21, 0x0, 0x0, 0x0, 0x109230), at 0xef6e7688
        [18] execute_java_dynamic_method(0xef0d1c6c, 0xee305908, 0xef733c1c, 0xef733c20, 0xef737000, 0x0), at 0xef6e6d2c
        [19] ThreadRT0(0xee305908, 0xef733c20, 0x0, 0x0, 0x0, 0x0), at 0xef701a34
        [20] start_func(0xef71e800, 0xee305908, 0xef7019dc, 0x0, 0x0, 0x0), at 0xef714a94
      ------------------Stack Trace end-------------------------------------

            tmasunw Tao Ma (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: