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

TextField.GetText() crashes

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P4
    • None
    • 1.1.7
    • client-libs
    • sparc
    • solaris_2.5.1

    Description



      Name: mf23781 Date: 04/29/99



      -------------------------------
      Problem Description
      -------------------------------

      A TextField which contains unusual characters (such as those which may come about from an encryption algorithm) crashes on a call to the GetText() method (and occasionally SetText()). A testcase is provided below. This problem only occurs on Solaris - the Testcase ran on Win32 for days without a hitch. See evaluation below for stack traces obtained from the core files.

      -------------------------------
      Testcase Instructions
      -------------------------------

      Compile and run the testcase provided below. This test creates a window with three "TextField" entry fields. The test loops (effectively forever) entering strings of random characters into the three textfields. After each loop, the textfields are removed from the window and creates them again before the next iteration.

      After a while (sometimes as many as 5000 iterations) the application crashes.

      -------------------------------
      Testcase
      -------------------------------


      import java.awt.*;
      import java.util.*;
      import java.io.*;

      public class TextFieldTest extends Panel
      {
          private static final int OUTERLIMIT = 1000000;
          private static final int LIMIT = 1000;
          TextField field1;
          TextField field2;
          TextField field3;
          Random r = new Random (System.currentTimeMillis());
          FileWriter f;
          private static final char[] hexchars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};

          public static void main (String args[])
          {
              TextFieldTest foo = new TextFieldTest();
      foo.init();

              Frame mainFrame = new Frame("Text Field Test");
      mainFrame.setSize(400,120);
      mainFrame.add("Center", foo);
              mainFrame.show();
      mainFrame.repaint();

      foo.run();

      System.exit(0);
          }

          public void init()
          {
              setBackground (Color.blue);
      setLayout (new BorderLayout());
      field1 = new TextField(35);
      field2 = new TextField(35);
      field3 = new TextField(35);
      add ("North", field1);
      add ("Center", field2);
      add ("South", field3);
              doLayout();
          }

          public void run()
          {
              int loop;
              int length;
              int iteration;
      byte[] value;
              String check;

              for (int q=0; q<OUTERLIMIT; q++)
      {
      try
      {
      f = new FileWriter ("TextFieldTest.results");

      loop = (int) (r.nextFloat() * LIMIT);
      for (int i=0; i<loop; i++)
      {
      length = (int) (r.nextFloat() * 512);
      try { f.write ("Length = " + length + "\n"); } catch (Exception e) {}
      value = new byte[length];
      for (int j=0; j<length; j++)
      {
      byte x = (byte) (r.nextFloat() * 256);
      value[j] = x;
      }
      try { f.write ("Value = " + buffToString(value) + "\n"); } catch (Exception e) {}
      try { f.flush (); } catch (Exception e) {}
      field1.setText (new String(value));
      check = field1.getText();


      length = (int) (r.nextFloat() * 512);
      try { f.write ("Length = " + length + "\n"); } catch (Exception e) {}
      value = new byte[length];
      for (int j=0; j<length; j++)
      {
      byte x = (byte) (r.nextFloat() * 256);
      value[j] = x;
      }
      try { f.write ("Value = " + buffToString(value) + "\n"); } catch (Exception e) {}
      try { f.flush (); } catch (Exception e) {}
      field2.setText (new String(value));
      check = field2.getText();

      length = (int) (r.nextFloat() * 512);
      try { f.write ("Length = " + length + "\n"); } catch (Exception e) {}
      value = new byte[length];
      for (int j=0; j<length; j++)
      {
      byte x = (byte) (r.nextFloat() * 256);
      // try { f.write (new Byte(x).toString() + " "); } catch (Exception e) {}
      value[j] = x;
      }
      try { f.write ("Value = " + buffToString(value) + "\n"); } catch (Exception e) {}
      try { f.flush (); } catch (Exception e) {}
      field3.setText (new String(value));
      check = field3.getText();
      }
      System.out.println ("-- iteration " + q + " complete (" + loop + ") --");

      remove (field1);
      remove (field2);
      remove (field3);

      init();
      }
      catch (Exception e)
      {
      System.out.println ("Unable to open file TextFieldTest.results ...");
      e.printStackTrace();
      }
      }
      System.out.println ("-- TEST COMPLETE --");
          }
        
          public String buffToString (byte[] value)
          {
              StringBuffer strbuf = new StringBuffer();
            
              for (int i = 0; i < value.length; i++)
      {
      int first = (value[i] >> 4) & 0x0f;
      int second = value[i] & 0x0f;

      strbuf.append(hexchars[first]);
      strbuf.append(hexchars[second]);
      }
            
              return strbuf.toString();
          }
      }


      -------------------------------
      Evaluation
      -------------------------------

      The testcase has been tried on JDK1.1.7B Production and Reference port. Stack traces (from running dbx against the core file) for each are provided here:

      JDK1.1.7B Solaris (Production)
      ==============================

      $dbx /usr/java/bin/sparc/native_threads/java_g core
      Reading symbolic information for java_g
      core file header read successfully
      Reading symbolic information for rtld /usr/lib/ld.so.1
      dbx: program is not active
      Reading symbolic information for libjava_g.so
      Reading symbolic information for libm.so.1
      Reading symbolic information for libdl.so.1
      Reading symbolic information for libX11.so.4
      Reading symbolic information for libsocket.so.1
      Reading symbolic information for libnsl.so.1
      Reading symbolic information for libthread.so.1
      Reading symbolic information for libc.so.1
      Reading symbolic information for libXext.so.0
      Reading symbolic information for libmp.so.2
      Reading symbolic information for libc_psr.so.1
      Reading symbolic information for libzip_g.so
      Reading symbolic information for en_UK.so.1
      Reading symbolic information for libawt_g.so
      Reading symbolic information for libXm.so.3
      Reading symbolic information for libXt.so.4
      Reading symbolic information for libSM.so.6
      Reading symbolic information for libICE.so.6
      Reading symbolic information for xlibi18n.so.2
      Reading symbolic information for xomEuro.so.2
      Reading symbolic information for ximlocal.so.2
      detected a multithreaded program
      dbx: program is not active
      t@1 (l@3) terminated by signal ABRT (Abort)
      dbx: warning: can't find file "/build/javavm/javavm11-1.1.7_06_FINAL-native/build/solaris/java/main/obj_g/sparc/native_threads/java.o"
      dbx: warning: see `help pathmap'
      dbx: warning: can't find file "/build/javavm/javavm11-1.1.7_06_FINAL-native/build/solaris/java/java/obj_g/sparc/native_threads/interrupt_md.o"
      dbx: warning: can't find file "/build/javavm/javavm11-1.1.7_06_FINAL-native/build/solaris/sun/awt/obj_g/sparc/native_threads/awt_TextField.o"
      dbx: warning: can't find file "/build/javavm/javavm11-1.1.7_06_FINAL-native/build/solaris/sun/awt/obj_g/sparc/native_threads/libstubs.o"
      dbx: warning: can't find file "/build/javavm/javavm11-1.1.7_06_FINAL-native/build/solaris/java/java/obj_g/sparc/native_threads/classruntime.o"
      dbx: warning: can't find file "/build/javavm/javavm11-1.1.7_06_FINAL-native/build/solaris/java/java/obj_g/sparc/native_threads/executeJava.o"
      dbx: warning: can't find file "/build/javavm/javavm11-1.1.7_06_FINAL-native/build/solaris/java/java/obj_g/sparc/native_threads/interpreter.o"
      dbx: warning: can't find file "/build/javavm/javavm11-1.1.7_06_FINAL-native/build/solaris/java/java/obj_g/sparc/native_threads/javai.o"


      (dbx) threads
      o> t@1 a l@3 ?() signal SIGABRT in _lwp_kill()
            t@2 b l@2 ?() LWP suspended in __signotifywait()
            t@3 ?() sleep on (unknown) in _swtch()
            t@4 _start() sleep on 0x27798 in _swtch()
            t@5 _start() sleep on 0xef5c8348 in _swtch()
            t@6 a l@1 _start() sleep on 0x229d0 in _lwp_sema_wait()
            t@7 a l@4 _start() sleep on 0x2331c in _lwp_sema_wait()
            t@8 _start() sleep on 0x22378 in _swtch()


      (dbx) where
      current thread: t@1
      =>[1] _lwp_kill(0x0, 0x6, 0xeffff244, 0xefffbe08, 0xef38ecb8, 0x0), at 0xef3394dc
        [2] signalHandlerPanic(0xb, 0xefffc348, 0xefffc090, 0xef5c6ad0, 0x20af4, 0x20ad4), at 0xef70535c
        [3] __libthread_segvhdlr(0xb, 0xefffc348, 0xefffc090, 0xef5c6ad0, 0x0, 0x0), at 0xef5b465c
        [4] __sighndlr(0xb, 0xefffc348, 0xefffc090, 0xef5b457c, 0x20af4, 0x20ad4), at 0xef5b6518
        ---- called from signal handler with signal 11 (SIGSEGV) ------
        [5] _memcpy(), at 0xef5910b0
        [6] _memcpy(0x0, 0x1337cac8, 0x12, 0x100, 0x60, 0x0), at 0xef59076c
        [7] ValidateString(0x1603d0, 0xed86e918, 0x1337c8e8, 0xee77842c, 0x1f1, 0x1f1), at 0xee66970c
        [8] SetValues(0x0, 0x1603d0, 0x0, 0xee77842c, 0x1, 0x0), at 0xee6913b0
        [9] CallSetValues(0x0, 0xefffe320, 0xefffe000, 0x1603d0, 0x132b93a8, 0xee690f70), at 0xee5c58d8
        [10] XtSetValues(0x1603d0, 0xee5f3c90, 0xee5f3c8c, 0x0, 0xe1478, 0xee786400), at 0xee5c5e9c
        [11] XtVaSetValues(0x1603d0, 0x0, 0xed86e918, 0x0, 0x0, 0x0), at 0xee5d9fd8
        [12] sun_awt_motif_MTextFieldPeer_setText(0xed66c808, 0xed67ddf0, 0x0, 0xffffffff, 0xfffffff8, 0xed86e912), at 0xef11ae34
        [13] Java_sun_awt_motif_MTextFieldPeer_setText_stub(0x258f4, 0xef727994, 0xef727994, 0x0, 0x0, 0x0), at 0xef16d418
        [14] invokeNativeMethod(0xed66c808, 0x16706c, 0x2, 0xef727994, 0x200, 0xeffff484), at 0xef675d6c
        [15] ExecuteJava(0xefffefb0, 0xef727994, 0x258c0, 0x258e4, 0x258cc, 0x1655bb), at 0xef6f981c
        [16] do_execute_java_method_vararg(0xef727994, 0xed66a0a8, 0x0, 0x0, 0xc8d68, 0x1), at 0xef697640
        [17] do_execute_java_method(0x0, 0xed66a0a8, 0x0, 0x0, 0xc8d68, 0x1), at 0xef696a0c
        [18] java_main(0xc8d68, 0x1, 0xef3a52e8, 0x2, 0xffffffff, 0xef7c16e1), at 0xef6e007c
        [19] main(0x2, 0xeffff314, 0xeffff320, 0x20800, 0x0, 0x0), at 0x10858





      JDK1.1.7B Solaris (Reference Port)
      ==================================

      $ dbx /usr/local/jdk1.1.7.FCS/bin/sparc/green_threads/java_g core
      Reading symbolic information for java_g
      core file header read successfully
      Reading symbolic information for rtld /usr/lib/ld.so.1
      dbx: program is not active
      Reading symbolic information for libjava_g.so
      Reading symbolic information for libm.so.1
      Reading symbolic information for libdl.so.1
      Reading symbolic information for libX11.so.4
      Reading symbolic information for libsocket.so.1
      Reading symbolic information for libnsl.so.1
      Reading symbolic information for libc.so.1
      Reading symbolic information for libXext.so.0
      Reading symbolic information for libmp.so.2
      Reading symbolic information for libc_psr.so.1
      Reading symbolic information for en_UK.so.1
      Reading symbolic information for libawt_g.so
      Reading symbolic information for libXm.so.3
      Reading symbolic information for libXt.so.4
      Reading symbolic information for libSM.so.6
      Reading symbolic information for libICE.so.6
      Reading symbolic information for xlibi18n.so.2
      Reading symbolic information for xomEuro.so.2
      Reading symbolic information for ximlocal.so.2
      program terminated by signal ABRT (Abort)
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/java/main/obj_g/sparc/green_threads/java.o"
      dbx: warning: see `help pathmap'
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/java/java/obj_g/sparc/green_threads/system_md.o"
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/java/java/obj_g/sparc/green_threads/interrupt_md.o"
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/sun/awt/obj_g/sparc/green_threads/awt_TextField.o"
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/sun/awt/obj_g/sparc/green_threads/libstubs.o"
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/java/java/obj_g/sparc/green_threads/classruntime.o"
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/java/java/obj_g/sparc/green_threads/executeJava.o"
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/java/java/obj_g/sparc/green_threads/interpreter.o"
      dbx: warning: can't find file "/usr/re/jdk1.1.7/WS/solaris/jdk1.1.7/build/solaris/java/java/obj_g/sparc/green_threads/javai.o"
      (dbx) threads
      dbx: not an MT program
      (dbx) where
      =>[1] _lwp_kill(0x0, 0x6, 0xefffcab8, 0xef3a577c, 0x18, 0xef707078), at 0xef3394dc
        [2] sysAbort(0xef707078, 0x0, 0xeffff224, 0xefffc8e8, 0xef38ecb8, 0x0), at 0xef6ee714
        [3] signalHandlerPanic(0xb, 0xefffced0, 0xefffcc18, 0x0, 0x0, 0x0), at 0xef70735c
        ---- called from signal handler with signal 11 (SIGSEGV) ------
        [4] _memcpy(), at 0xef4f0630
        [5] SetValuesPrehook(0xedf8c200, 0x5f14e28, 0xe9228, 0x5f14e40, 0xefffd0c8, 0xf29d8), at 0xede3cefc
        [6] SetValuesRootWrapper(0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0xefffd0c8, 0xedf8be18), at 0xede32308
        [7] CallSetValues(0x0, 0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0xede32254), at 0xef0458d8
        [8] CallSetValues(0x0, 0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0x1), at 0xef045870
        [9] CallSetValues(0x0, 0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0x1), at 0xef045870
        [10] CallSetValues(0x0, 0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0x1), at 0xef045870
        [11] CallSetValues(0x0, 0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0x1), at 0xef045870
        [12] CallSetValues(0x0, 0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0x1), at 0xef045870
        [13] CallSetValues(0x0, 0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0x1), at 0xef045870
        [14] CallSetValues(0x0, 0xefffd868, 0xefffd548, 0xe9228, 0x5f14e40, 0x1), at 0xef045870
        [15] XtSetValues(0xe9228, 0xef073c90, 0xef073c8c, 0x0, 0xc4108, 0xedf8bda8), at 0xef045e9c
        [16] XtVaSetValues(0xe9228, 0x0, 0x21, 0x0, 0x0, 0xefffdc54), at 0xef059fd8
        [17] XmImSetValues(0xd, 0xedf80814, 0xedf80808, 0xefffdd64, 0x5f06094, 0x0), at 0xede90d98
        [18] SetValues(0xefffe340, 0x0, 0x5e7b090, 0xefffdd64, 0xd, 0x3), at 0xede66d44
        [19] CallSetValues(0x0, 0xefffe340, 0xefffe020, 0x5e7b090, 0x5f14e58, 0xede66108), at 0xef0458d8
        [20] XtSetValues(0x5e7b090, 0xef073c90, 0xef073c8c, 0x0, 0xc4108, 0xedf8061c), at 0xef045e9c
        [21] XtVaSetValues(0x5e7b090, 0x0, 0xee3e9700, 0x0, 0x0, 0x0), at 0xef059fd8
        [22] sun_awt_motif_MTextFieldPeer_setText(0xee331598, 0xee32dcf8, 0x1, 0x48, 0x0, 0x0), at 0xef10fd98
        [23] Java_sun_awt_motif_MTextFieldPeer_setText_stub(0x24168, 0xef733418, 0xef733418, 0x0, 0x0, 0x0), at 0xef15b280
        [24] invokeNativeMethod(0xee331598, 0x10fdf4, 0x2, 0xef733418, 0x0, 0xeffff466), at 0xef67ef14
        [25] ExecuteJava(0xefffefb8, 0xef733418, 0x24134, 0x24158, 0x24140, 0xb2e9b), at 0xef6ff184
        [26] do_execute_java_method_vararg(0xef733418, 0xee304050, 0x0, 0x0, 0x8ac48, 0x1), at 0xef69fde8
        [27] do_execute_java_method(0x0, 0xee304050, 0x0, 0x0, 0x8ac48, 0x1), at 0xef69f1b4
        [28] java_main(0x8ac48, 0x1, 0xef3a52e8, 0x2, 0xffffffff, 0xef7c16e1), at 0xef6e6e74
        [29] main(0x2, 0xeffff2f4, 0xeffff300, 0x20800, 0x0, 0x0), at 0x10948
      (dbx)






      (Review ID: 57634)

      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              ehawkessunw Eric Hawkes (Inactive)
              miflemi Mick Fleming
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: