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

Displaying an empty Choice widget crashes. Solaris only.



    • Subcomponent:
    • Resolved In Build:
    • CPU:
    • OS:
      generic, solaris_2.4
    • Verification:


          "Finalizer thread" (TID:0xee3003b0, sys_thread_t:0xef490de0) prio=1
          "Async Garbage Collector" (TID:0xee300368, sys_thread_t:0xef4c0de0) prio=1
          "Idle thread" (TID:0xee300320, sys_thread_t:0xef4f0de0) prio=0
          "clock handler" (TID:0xee3001f8, sys_thread_t:0xef5b0de0) prio=11
          "main" (TID:0xee3000a0, sys_thread_t:0x83f68) prio=5
      Monitor Cache Dump:
          unknown key (key=0xef4c0de0): unowned
              Waiting to be notified:
                  "Async Garbage Collector"
          sun.awt.motif.MToolkit@EE302FF0/EE33F7E8 (key=0xee302ff0): monitor owner: "thread applet-QuickTest"
              Waiting to be notified:
          java.awt.Frame@EE303778/EE341708 (key=0xee303778): monitor owner: "thread applet-QuickTest"
          java.awt.Choice@EE303808/EE341B40 (key=0xee303808): monitor owner: "thread applet-QuickTest"
          java.awt.Panel@EE303790/EE3417A8 (key=0xee303790): monitor owner: "thread applet-QuickTest"
          sun.awt.motif.MFramePeer@EE3030A8/EE33FA60 (key=0xee3030a8): monitor owner: "AWT-Motif"
          sun.awt.ScreenUpdater@EE3033A0/EE3401F8 (key=0xee3033a0): unowned
              Waiting to be notified:
                  "Screen Updater"
      Registered Monitor Dump:
              Waiting to be notified:
                  Finalize me queue lock: "Finalizer thread"
              Waiting to be notified:
                  Thread queue lock: "main"
              Waiting to be notified:
                  Class lock: Java stack lock: Code rewrite lock: Heap lock: Has finalization queue lock: Monitor IO lock: Child death monitor: Event monitor: I/O monitor: Alarm monitor: "clock handler"
          monitor owner: "thread applet-QuickTest"
      Thread Alarm Q:
          sys_thread_t 0xef4c0de0 [Timeout in 757 ms]
          Sbrk lock: Monitor cache lock: Monitor registry: Abort (core dumped)
      Solaris only: Displaying an empty Choice widget crashes

      Steps to reproduce
      Compile and run the attached code

      import java.awt.*;
      import java.applet.Applet;

      public class CT extends Applet

          public void init()
             add(new Choice());

          public static void main(String args[])
             AppletFrame.startApplet("CT", "Choice Test", args);

      /* Generic Applet to Application Frame
       * @(#)AppletFrame.java 1.1 14 Dec 1995 14:41:30
       * 1.4 12/02/95 15:28:07
       * @author Kevin A. Smith
       * Directions for use:
       * In order to convert an applet to an application you must provide
       * two things: A main() function in the class body of the applet
       * and an AWT Frame window for the application to exist in. If your
       * applet requires parameters from the HTML Applet tag, you will need
       * to do additional work.
       * Here's a sample main() function that you can add to your applet class:
       * public static void main(String args[])
       * {
       * AppletFrame.startApplet( <ClassName>, "Application Title", args);
       * }
       * The class AppletFrame provides a simple AWT Frame window for running
       * applications.

      import java.awt.Frame;
      import java.awt.Event;
      import java.awt.Dimension;
      import java.applet.Applet;

      // Applet to Application Frame window
      class AppletFrame extends Frame

          public static void startApplet(String className,
                                         String title,
                                         String args[])
             // local variables
             Applet a;
             Dimension appletSize;

                // create an instance of your applet class
                a = (Applet) Class.forName(className).newInstance();
             catch (ClassNotFoundException e) { return; }
             catch (InstantiationException e) { return; }
             catch (IllegalAccessException e) { return; }

             // initialize the applet
             // create new application frame window
             AppletFrame f = new AppletFrame(title);
             // add applet to frame window
             f.add("Center", a);
             // resize frame window to fit applet
             // assumes that the applet sets its own size
             // otherwise, you should set a specific size here.
             appletSize = a.size();

             // show the window
          } // end startApplet()
          // constructor needed to pass window title to class Frame
          public AppletFrame(String name)
             // call java.awt.Frame(String) constructor

          // needed to allow window close
          public boolean handleEvent(Event e)
             // Window Destroy event
             if (e.id == Event.WINDOW_DESTROY)
                // exit the program
                return true;
             // it's good form to let the super class look at any
             // unhandled events
             return super.handleEvent(e);

          } // end handleEvent()

      } // end class AppletFrame

      The description field as copied from bug report 1235627 follows:

      Doing a Component.add(Choice c) when "c" has had no items causes
      a SIGSEGV. This is isn't a useful thing to do, but dumping core isn't a nice
      outcome. Perhaps turning it into a one-choice ("null") button or throwing
      an exception would be a better way to handle it.

      The following is a simple test case:

      import java.awt.*;
       * dumps core with SIGSEGV
      public class ChoiceTest extends Frame {
          Choice c1;
          public ChoiceTest() {
      c1 = new Choice();
      add("North", c1);
          public static void main(String args[]) {
      new ChoiceTest();


      Original bug report (before customer realized they had done no addItems
      in this particular case):

      *** This is a severe problem, is there a known workaround? ***

      In Espresso, we have a number of dialog boxes where the strings on Choice component must be changed, just like list boxes.

      In list boxes, we clear() all strings and then addItem() the new strings.

      In Choice menus, there is no clear() method so we create a new Choice component on the fly. Below is a pruned version of our code. If this is not a known problem or is not imminently reproducable, lets us know, we can fabricate a complete example:

          public void addin(Dlg dlg) {
              cmp.show(false); // hack -just undisplay old one
              cmp = new Choice();
              for ( int ix = 0; ix < num_strs; ix++ )
      // cmp.select(0); // errors, says 0 invalid index!

      ***************** OUTPUT *************************

      Any workaround suggestions:

      SIGSEGV 11* segmentation violation
          si_signo [11]: SIGSEGV 11* segmentation violation
          si_errno [0]: Error 0
          si_code [1]: SEGV_ACCERR [addr: 0xfffffffc]

          stackbase=EE13F000, stackpointer=EE13DF20

      Full thread dump:
          "Image Fetcher 3" (TID:0xee8fcd88, sys_thread_t:0xee094de0) prio=8
          "Image Fetcher 2" (TID:0xee8fcd20, sys_thread_t:0xee0b6de0) prio=8
          "Image Fetcher 1" (TID:0xee8fccb8, sys_thread_t:0xee0d8de0) prio=8
          "Image Fetcher 0" (TID:0xee8fcc30, sys_thread_t:0xee0fade0) prio=8
          "duker" (TID:0xee8fc990, sys_thread_t:0xee11cde0) prio=1
          "listener" (TID:0xee8fc968, sys_thread_t:0xee13ede0) prio=1 *current thread*
          "Screen Updater" (TID:0xee8e24b8, sys_thread_t:0xee17ade0) prio=4
          "AWT-Motif" (TID:0xee8e2148, sys_thread_t:0xee19cde0) prio=5
          "AWT-Input" (TID:0xee8e2120, sys_thread_t:0xee1bede0) prio=5
          "thread applet-starter.class" (TID:0xee8e1ee8, sys_thread_t:0xee4bede0) prio=6
          "Finalizer thread" (TID:0xee8df370, sys_thread_t:0xee4f5de0) prio=1
          "Async Garbage Collector" (TID:0xee8df318, sys_thread_t:0xee517de0) prio=1
          "Idle thread" (TID:0xee8df2a0, sys_thread_t:0xee539de0) prio=0
          "clock handler" (TID:0xee8df1f8, sys_thread_t:0xee55bde0) prio=11
          "main" (TID:0xee8df0a0, sys_thread_t:0x745f0) prio=5
      Monitor Cache Dump:
          java.awt.Choice@EE8F29D8/EE95C9B8 (key=0xee8f29d8): monitor owner: "listener"
          java.util.Vector@EE8FCDF0/EE9A06B0 (key=0xee8fcdf0): unowned
          Waiting to be notified:
              "Image Fetcher 1"
              "Image Fetcher 2"
              "Image Fetcher 3"
              "Image Fetcher 0"
          unknown key (key=0xee11cde0): monitor owner: "duker"
          sun.awt.motif.MToolkit@EE8E2108/EE91E210 (key=0xee8e2108): monitor owner: "listener"
          Waiting to enter:
          Waiting to be notified:
          sun.awt.ScreenUpdater@EE8E24B8/EE91EC28 (key=0xee8e24b8): unowned
          Waiting to be notified:
              "Screen Updater"
          unknown key (key=0xee517de0): unowned
          Waiting to be notified:
              "Async Garbage Collector"
          sun.applet.AppletViewerPanel@EE8E1D80/EE91D198 (key=0xee8e1d80): unowned
          Waiting to be notified:
              "thread applet-starter.class"
          Dlg@EE8F1498/EE957498 (key=0xee8f1498): monitor owner: "listener"
      Registered Monitor Dump:
          Finalize me queue lock: unowned
          Waiting to be notified:
              "Finalizer thread"
          Thread queue lock: unowned
          Waiting to be notified:
          Class lock: unowned
          Java stack lock: unowned
          Code rewrite lock: unowned
          Heap lock: unowned
          Has finalization queue lock: unowned
          Monitor IO lock: unowned
          Child death monitor: unowned
          Event monitor: unowned
          I/O monitor: unowned
          Alarm monitor: unowned
          Waiting to be notified:
              "clock handler"
          Sbrk lock: unowned
          Monitor cache lock: unowned
          Monitor registry: monitor owner: "listener"
      Thread Alarm Q:
          sys_thread_t 0xee517de0 [Timeout in 231 ms]

      // Barry Zane Vice President of Technology
      // Applix, Inc 508-870-0300 x226 ###@###.###

      The description field as copied from bug report 1240186 follows:

      import java.awt.*;
      public class testcase extends java.applet.Applet {

      // a slot to hold an arbitrary object pointer that can
      // be filled in by the app. and referenced in actions
      public Object arg;

      public Choice menubutton_1;

      //methods to support form introspection
      public static String names[] = {
      public String[] getNames() {
      return names;

      //There should be an easier way to do this
      public Object[] getWidgets() {
      Object[] list = new Object[1];
      list[0] = menubutton_1;
      return list;

      public void init() {

      // main panel
      GridBagLayout grid = new GridBagLayout();
      int rowHeights[] = {0,30,30,30};
      int columnWidths[] = {0,30,30,30};
      double rowWeights[] = {0.0,0.0,0.0,0.0};
      double columnWeights[] = {0.0,0.0,0.0,0.0};
      grid.rowHeights = rowHeights;
      grid.columnWidths = columnWidths;
      grid.rowWeights = rowWeights;
      grid.columnWeights = columnWeights;

      menubutton_1 = new Choice();
      /* menubutton_1.addItem("xyz"); */

      // Geometry management
      GridBagConstraints con = new GridBagConstraints();
      con.gridx = 2;
      con.gridy = 2;
      con.anchor = GridBagConstraints.CENTER;
      con.fill = GridBagConstraints.NONE;
      grid.setConstraints(menubutton_1, con);

      // Resize behavior management and parent heirarchy

      // Give the application a chance to do its initialization

      public boolean handleEvent(Event event) {
      return super.handleEvent(event);

      public static void main(String[] args) {
          Frame f = new Frame("testcase Test");
          testcase win = new testcase();
          f.add("Center", win);

      private void reset(GridBagConstraints con) {
          con.gridx = GridBagConstraints.RELATIVE;
          con.gridy = GridBagConstraints.RELATIVE;
          con.gridwidth = 1;
          con.gridheight = 1;
          con.weightx = 0;
          con.weighty = 0;
          con.anchor = GridBagConstraints.CENTER;
          con.fill = GridBagConstraints.NONE;
          con.insets = new Insets(0, 0, 0, 0);
          con.ipadx = 0;
          con.ipady = 0;


      The description field as copied from bug report 1240954 follows:

      1) Create a gridbag.
      2) Add a Choice control to it.
      3) At runtime you get the segmentation fault shown below:


      ******* QuickTest.html *************************************************

      <applet code="QuickTest" width=200 height=50> </applet>

      ******* QuickTest.java *************************************************

      import java.awt.*;
      import java.lang.*;
      import java.applet.*;

      public class QuickTest extends Applet {

        Choice testChoice;
        Frame theFrame;

        public void init() {

          theFrame = new Frame();

          Panel topPanel = new Panel();

          GridBagLayout gridbag = new GridBagLayout();
          GridBagConstraints gbC = new GridBagConstraints();
          Component component = null;


          // Backup id Choice
          gbC.gridx = 0;
          gbC.gridy = 0;
          gbC.anchor = GridBagConstraints.SOUTHWEST;
          testChoice = new Choice();
          component = testChoice;
          // VVVVVVVV Commenting out this line causes core dump VVVVVVV
          // ((Choice)component).addItem("This is a test");
          // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          gridbag.setConstraints(component, gbC);
          System.out.println("DEBUG - added...");

          theFrame.add("Center", topPanel);

          public void clear_constraints(GridBagConstraints gbConstraints) {
            gbConstraints.gridx = -1;
            gbConstraints.gridy = -1;
            gbConstraints.gridwidth = 1;
            gbConstraints.gridheight = 1;
            gbConstraints.weightx = 0;
            gbConstraints.weighty = 0;
            gbConstraints.fill = GridBagConstraints.NONE;
            gbConstraints.anchor = GridBagConstraints.CENTER;

      ******* SEGMENTATION VIOLATION: ********************************************

      SIGSEGV 11* segmentation violation
          si_signo [11]: SIGSEGV 11* segmentation violation
          si_errno [0]: Error 0
          si_code [1]: SEGV_ACCERR [addr: 0xfffffffc]

              stackbase=EF461000, stackpointer=EF45FE68

      Full thread dump:
          "Screen Updater" (TID:0xee3033a0, sys_thread_t:0xef0d0de0) prio=4
          "AWT-Motif" (TID:0xee303030, sys_thread_t:0xef100de0) prio=5
          "AWT-Input" (TID:0xee303008, sys_thread_t:0xef130de0) prio=5
          "thread applet-QuickTest" (TID:0xee302e48, sys_thread_t:0xef460de0) prio=6 *current thread*


          Issue Links



              amfowler Anne Fowler (Inactive)
              kasmithsunw Kevin Smith (Inactive)
              0 Vote for this issue
              0 Start watching this issue