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

Repeatedly creating/destroying windows under NT crashes JVM

    XMLWordPrintable

Details

    • x86
    • solaris_2.5.1

    Description

      The following class will bring up a panel with a button, clicking the button will close the window and repeat the process. When this is run on NT if you repeatedly click on the button eventually you get an error where an instruction is trying to reference memory at 0x10, which could not be written, thus killing the program. I was not able to get this to happen under Solaris, only on NT. While this example may seem contrived it is taken from a much larger program where it crashes quite regularly.
      import java.awt.*;
      import java.awt.event.*;
      import java.util.*;

      public class Crasher extends Object implements ActionListener
      {
        Vector events;
        Window window;

        static Frame offscreenFrame;

      static Frame offscreenFrame()
      {
        if (offscreenFrame == null)
        {
          // Need to grab the single component lock to prevent deadlock with
          // AWT thread.
          synchronized (new Canvas().getTreeLock())
          {
            // Check again since another thread may have gotten through
            // the first check above and gotten the lock.
            if (offscreenFrame == null)
            {
      offscreenFrame = new Frame();
      offscreenFrame.setBounds(-100, -100, 50, 50);
      offscreenFrame.setLayout(new FlowLayout());
      offscreenFrame.setVisible(true);
      offscreenFrame.setVisible(false);
            }
          }
        }
        return offscreenFrame;
      }

      public Crasher()
      {
        events = new Vector();
        this.createWindow();
        this.run();
      }

      private void createWindow()
      {
        Button button;

        System.out.println("Creating window!");
        if(window != null)
        {
          System.out.println("closing!");
          window.setVisible(false);
          window.dispose();
        }
        window = new Window(Crasher.offscreenFrame());
        window.setBounds(100, 100, 200, 200);
        button = new Button();
        button.setLabel("foo");
        button.addActionListener(this);
        window.add(button);
        window.setVisible(true);
        window.toFront();
        System.out.println("created window!");
      }

      public void actionPerformed(ActionEvent e)
      {
        synchronized(events)
        {
          events.addElement(e);
          events.notify();
        }
      }

      private void run()
      {
        for(;;)
        {
          try
          {
            synchronized(events)
            {
      events.wait();
            }
          } catch (Exception e) {}
          if(events.size() > 0)
          {
            this.createWindow();
            events.removeElementAt(0);
          }
        }
      }

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

      Attachments

        Activity

          People

            lbunnisunw Lara Bunni (Inactive)
            svioletsunw Scott Violet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: