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

adding zero-item Choice to Container causes SIGSEGV

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.4

      Description

      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() {
      super("ChoiceTest");
      c1 = new Choice();
      add("North", c1);
      pack();
      show();
          }
          public static void main(String args[]) {
      new ChoiceTest();
          }
      }

      --bruce.walker@east

      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();
              cmp.reshape(xpos+lwid+4,ypos-2,70,25);
              for ( int ix = 0; ix < num_strs; ix++ )
                  cmp.addItem(strs[ix]);
      // cmp.select(0); // errors, says 0 invalid index!
              dlg.add(cmp);
          }

      ***************** 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
          java.lang.Object.wait(Object.java)
          sun.awt.image.ImageFetcher.nextImage(ImageFetcher.java:81)
          sun.awt.image.ImageFetcher.run(ImageFetcher.java:96)
          "Image Fetcher 2" (TID:0xee8fcd20, sys_thread_t:0xee0b6de0) prio=8
          java.lang.Object.wait(Object.java)
          sun.awt.image.ImageFetcher.nextImage(ImageFetcher.java:81)
          sun.awt.image.ImageFetcher.run(ImageFetcher.java:96)
          "Image Fetcher 1" (TID:0xee8fccb8, sys_thread_t:0xee0d8de0) prio=8
          java.lang.Object.wait(Object.java)
          sun.awt.image.ImageFetcher.nextImage(ImageFetcher.java:81)
          sun.awt.image.ImageFetcher.run(ImageFetcher.java:96)
          "Image Fetcher 0" (TID:0xee8fcc30, sys_thread_t:0xee0fade0) prio=8
          java.lang.Object.wait(Object.java)
          sun.awt.image.ImageFetcher.nextImage(ImageFetcher.java:81)
          sun.awt.image.ImageFetcher.run(ImageFetcher.java:96)
          "duker" (TID:0xee8fc990, sys_thread_t:0xee11cde0) prio=1
          AxViewer.run(AxViewer.java:1189)
          java.lang.Thread.run(Thread.java)
          "listener" (TID:0xee8fc968, sys_thread_t:0xee13ede0) prio=1 *current thread*
          sun.awt.motif.MChoicePeer.initialize(MChoicePeer.java:35)
          sun.awt.motif.MComponentPeer.<init>(MComponentPeer.java:86)
          sun.awt.motif.MChoicePeer.<init>(MChoicePeer.java:40)
          sun.awt.motif.MToolkit.createChoice(MToolkit.java:81)
          java.awt.Choice.addNotify(Choice.java:55)
          java.awt.Container.add(Container.java:143)
          java.awt.Container.add(Container.java:102)
          Widget.addin(Dlg.java:501)
          AxwChoice.addin(Dlg.java:689)
          AxwChoice.newstrs(Dlg.java:698)
          Dlg.ctrl_xxx(Dlg.java:168)
          AxViewer.run(AxViewer.java:1247)
          java.lang.Thread.run(Thread.java)
          "Screen Updater" (TID:0xee8e24b8, sys_thread_t:0xee17ade0) prio=4
          java.lang.Object.wait(Object.java)
          sun.awt.ScreenUpdater.nextEntry(ScreenUpdater.java:75)
          sun.awt.ScreenUpdater.run(ScreenUpdater.java:95)
          "AWT-Motif" (TID:0xee8e2148, sys_thread_t:0xee19cde0) prio=5
          java.lang.Thread.run(Thread.java)
          "AWT-Input" (TID:0xee8e2120, sys_thread_t:0xee1bede0) prio=5
          "thread applet-starter.class" (TID:0xee8e1ee8, sys_thread_t:0xee4bede0) prio=6
          java.lang.Object.wait(Object.java)
          sun.applet.AppletPanel.getNextEvent(AppletPanel.java:154)
          sun.applet.AppletPanel.run(AppletPanel.java:174)
          java.lang.Thread.run(Thread.java)
          "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:
              "AWT-Input"
          Waiting to be notified:
              "AWT-Motif"
          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:
              "main"
          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 ###@###.###

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              amfowler Anne Fowler (Inactive)
              Reporter:
              duke J. Duke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: