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

Repeated adding/removing components using threads causes VM to crash

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 1.1.3
    • Fix Version/s: 1.1.5
    • Component/s: client-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      1.1.5
    • CPU:
      sparc
    • OS:
      solaris_2.5.1
    • Verification:
      Verified

      Description

      The code below causes the VM to consistently crash (70% of the time)
      Customer is using Solaris 2.5.1 with latest JDK 1.1.3.
      Although same problem exhibited when using
      Microsoft Windows '95 4.00.950a Compact/Pentium using JDK 1.1.2

      The test case is a simple app that repeatedly adds and removes components
      from panels using threads. An added thread in the test case monitor
      the heap size while the application runs.

      import java.awt.*;

      //
      // Java VM crasher originally composed by Hugh ODonoghue (CBOT) 6/27/97,
      // modified by John Lindberg (SMCC) 8/13/97
      //
      public class AWTTest {
      public static void main(String args[]) {

      monitorThread m = new monitorThread();
      m.start();

      AWTFrame f = new AWTFrame();
      // -- "POINT A" --
      AWTThread t1 = new AWTThread(f.panel1, "1");
      AWTThread t2 = new AWTThread(f.panel2, "2");
      AWTThread t3 = new AWTThread(f.panel3, "3");
      t1.start();
      t2.start();
      t3.start();
      f.setSize(600, 300); // <- Moving these two lines to "POINT A"
      f.show(); // <- greatly increases reliability.
      }
      }

      class AWTFrame extends Frame {
      Panel panel1;
      Panel panel2;
      Panel panel3;

      public AWTFrame() {

      super();
      setLayout(new GridLayout(1, 3));
      panel1 = new Panel();
      panel2 = new Panel();
      panel3 = new Panel();
      add(panel1);
      add(panel2);
      add(panel3);
      }
      }

      class AWTThread extends Thread {
      Panel p;
      Button b;
      Label l;
      Checkbox c;
      String id;

      AWTThread(Panel p, String id) {
      this.p = p;
      this.id = id;
      }

      public void run() {
      int i = 0;

      try {
      b = new Button("Test Button");
      l = new Label ("Test Label");
      c = new Checkbox("Test Checkbox");
      while (true) {
      System.out.println("Thread: " + id + " Test: " + i);

      p.add(b);
      p.add(l);
      p.add(c);
      sleep(200);
      p.remove(b);
      p.remove(l);
      p.remove(c);
      i++;
      //System.gc();
      }
      }
      catch (Exception e) {
      System.out.println("Exception: " + e);
      }
      }
      }

      class monitorThread extends Thread {
      Runtime r;

      public monitorThread() {
      r = Runtime.getRuntime();
      }

      public void run() {
      try {
      while (true) {
      sleep(500);
      System.out.println("Available heap: " + r.freeMemory());
      }
      }
      catch (Exception e) {
      System.out.println("Exception: " + e);
      }
      }
      }


      Due to the synchronization nature of the problem (dealing with threads),
      the errors produced may be different at the the time of the crash.
      Here is an output of one crash:

      jakarta:/home/meiphen/JAVA/3021361.awt 8 % !!
      java AWTTest
      Thread: 1 Test: 0
      Thread: 2 Test: 0
      Thread: 3 Test: 0
      Thread: 1 Test: 1
      Thread: 2 Test: 1
      Thread: 3 Test: 1
      Available heap: 892104
      Thread: 1 Test: 2
      Thread: 2 Test: 2
      Thread: 3 Test: 2
      Thread: 1 Test: 3
      Thread: 2 Test: 3
      Thread: 3 Test: 3
      Available heap: 840168
      Thread: 1 Test: 4
      Thread: 2 Test: 4
      Thread: 3 Test: 4
      Thread: 1 Test: 5
      Thread: 2 Test: 5
      Thread: 3 Test: 5
      Thread: 1 Test: 6
      Thread: 2 Test: 6
      Thread: 3 Test: 6
      Available heap: 834152
      Thread: 1 Test: 7
      SIGSEGV 11* segmentation violation
          si_signo [11]: SIGSEGV 11* segmentation violation
          si_errno [0]: Error 0
          si_code [1]: SEGV_ACCERR [addr: 0x0]

              stackbase=EFFFF6C0, stackpointer=EFFFECC8

      Full thread dump:
          "AWT-Motif" (TID:0xee305000, sys_thread_t:0xef0d0de0, state:CW) prio=5
              java.lang.Thread.run(Thread.java)
          "AWT-Input" (TID:0xee304fe0, sys_thread_t:0xef100de0, state:CW) prio=5
          "AWT-EventQueue-0" (TID:0xee304c68, sys_thread_t:0xef130de0, state:CW) prio=5
              java.lang.Object.wait(Object.java)
              java.awt.EventQueue.getNextEvent(EventQueue.java:118)
              java.awt.EventDispatchThread.run(EventDispatchThread.java:55)
          "Thread-7" (TID:0xee303e90, sys_thread_t:0xef260de0, state:MW) prio=5
              java.awt.Container.remove(Container.java:351)
              AWTThread.run(AWTTest.java:71)
          "Thread-6" (TID:0xee303e40, sys_thread_t:0xef290de0, state:MW) prio=5
              java.awt.Container.remove(Container.java:351)
              AWTThread.run(AWTTest.java:71)
          "Thread-5" (TID:0xee303df0, sys_thread_t:0xef2c0de0, state:MW) prio=5
              sun.awt.motif.MComponentPeer.<init>(MComponentPeer.java:106)
              sun.awt.motif.MLabelPeer.<init>(MLabelPeer.java:45)
              sun.awt.motif.MToolkit.createLabel(MToolkit.java:73)
              java.awt.Label.addNotify(Label.java:101)
              java.awt.Container.addImpl(Container.java:284)
              java.awt.Container.add(Container.java:162)
              AWTThread.run(AWTTest.java:67)
          "Thread-4" (TID:0xee303a58, sys_thread_t:0xef2f0de0, state:CW) prio=5
              monitorThread.run(AWTTest.java:93)
          "Finalizer thread" (TID:0xee300220, sys_thread_t:0xef320de0, state:CW) prio=1
          "Async Garbage Collector" (TID:0xee3001d8, sys_thread_t:0xef350de0, state:CW) prio=1
          "Idle thread" (TID:0xee300190, sys_thread_t:0xef380de0, state:R) prio=0
          "Clock" (TID:0xee3000d0, sys_thread_t:0xef3b0de0, state:CW) prio=12
          "main" (TID:0xee3000a8, sys_thread_t:0x40ef0, state:R) prio=5 *current thread*
              sun.awt.motif.MComponentPeer.<init>(MComponentPeer.java:106)
              sun.awt.motif.MButtonPeer.<init>(MButtonPeer.java:33)
              sun.awt.motif.MToolkit.createButton(MToolkit.java:61)
              java.awt.Button.addNotify(Button.java:74)
              java.awt.Container.addNotify(Container.java:1019)
              java.awt.Panel.addNotify(Panel.java:67)
              java.awt.Container.addNotify(Container.java:1019)
              java.awt.Window.addNotify(Window.java:101)
              java.awt.Frame.addNotify(Frame.java:145)
              java.awt.Window.show(Window.java:130)
              AWTTest.main(AWTTest.java:22)
      Monitor Cache Dump:
          <unknown key> (0xef2f0de0): <unowned>
              Waiting to be notified:
                  "Thread-4"
          <unknown key> (0xef350de0): <unowned>
              Waiting to be notified:
                  "Async Garbage Collector"
          java.awt.EventQueue@EE304C18/EE352898: <unowned>
              Waiting to be notified:
                  "AWT-EventQueue-0"
          sun.awt.motif.MToolkit@EE304BE8/EE3527A8: owner "main" (0x40ef0, 1 entry)
              Waiting to enter:
                  "Thread-5"
              Waiting to be notified:
                  "AWT-Motif"
          java.lang.Object@EE303BB0/EE34E238: owner "Thread-5" (0xef2c0de0, 1 entry)
              Waiting to enter:
                  "Thread-6"
                  "Thread-7"
      Registered Monitor Dump:
          Thread queue lock: <unowned>
          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"
          Monitor IO lock: <unowned>
          Child death monitor: <unowned>
          Event monitor: <unowned>
          I/O monitor: owner "AWT-Input" (0xef100de0, 1 entry)
          Alarm monitor: <unowned>
              Waiting to be notified:
                  "Clock"
          Sbrk lock: <unowned>
          Monitor cache expansion lock: <unowned>
          Monitor registry: owner "main" (0x40ef0, 1 entry)
      Thread Alarm Q:
          sys_thread_t 0xef2f0de0 [Timeout in 171 ms]
          sys_thread_t 0xef350de0 [Timeout in 224 ms]
      Abort (core dumped)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tbell Tim Bell
              Reporter:
              mchansunw Mei Chan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: