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

crash when using volatile field and when SQE runs CompileTheWorld admswt10.jar

XMLWordPrintable

    • rc
    • sparc
    • solaris_7
    • Verified

      This test causes crash when used with -server. If I remove the volatile keyword from the checksum field then the crash does not occur. Happens on winNT. I
      attached the input file that I used when I saw this occur.

      import java.io.*;

      public class Blah {

          static final int ITERATIONS = 60000;

          public static void main(String [] args) throws Exception {
              for (int x=0; x<10; x++) {
                  test1(false);
                  test2(false);
                  test3(false);
              }
              test1(true);
              test2(true);
              test3(true);
          }

          volatile static long checksum = 0;

          private static void test1(boolean reportResult) throws Exception {
              FileInputStream fis = new FileInputStream("inputfile");
              FileOutputStream fos = new FileOutputStream("outputfile");

              DataInputStream dis = new DataInputStream(new BufferedInputStream(fis));
              DataOutputStream dos=new DataOutputStream(newBufferedOutputStream(fos));

              long check = 0;
              long startTime = System.currentTimeMillis();
              for (int x=0; x<ITERATIONS; x++) {
                  short s = dis.readShort();
                  dos.writeShort(s);
                  check += s;
              }
              long endTime = System.currentTimeMillis();
              long totalTime = endTime - startTime;
              if (reportResult)
                  reportResult("readShort", "milliseconds", totalTime);

              dis.close();
              dos.close();
              checksum = check;
              return;
          }

          private static void test2(boolean reportResult) throws Exception {
              FileInputStream fis = new FileInputStream("inputfile");
              FileOutputStream fos = new FileOutputStream("outputfile");

              DataInputStream dis = new DataInputStream(new BufferedInputStream(fis));
              DataOutputStream dos=new DataOutputStream(newBufferedOutputStream(fos));

              long check = 0;
              long startTime = System.currentTimeMillis();
              for (int x=0; x<ITERATIONS; x++) {
                  int s = dis.readInt();
                  s = dis.readInt();
                  dos.writeInt(s);
                  dos.writeInt(s);
                  check += s;
              }
              long endTime = System.currentTimeMillis();
              long totalTime = endTime - startTime;
              if (reportResult)
                  reportResult("readInt", "milliseconds", totalTime);

              dis.close();
              dos.close();
              checksum = check;
              return;
          }

          private static void test3(boolean reportResult) throws Exception {
              FileInputStream fis = new FileInputStream("inputfile");
              FileOutputStream fos = new FileOutputStream("outputfile");

              DataInputStream dis = new DataInputStream(new BufferedInputStream(fis));
              DataOutputStream dos=new DataOutputStream(newBufferedOutputStream(fos));

              long check = 0;
              long startTime = System.currentTimeMillis();
              for (int x=0; x<ITERATIONS; x++) {
                  long s = dis.readLong(); s = dis.readLong();
                  dos.writeLong(s); dos.writeLong(s);
                  check += s;
              }
              dos.flush();

              long endTime = System.currentTimeMillis();
              long totalTime = endTime - startTime;
              if (reportResult)
                  reportResult("readLong", "milliseconds", totalTime);

              dis.close();
              dos.close();
              checksum = check;
              return;
          }

          private static void reportResult(String label, String unit, long result) {
              StringBuffer message = new StringBuffer(100);
              message.append(label + " completed in " + result + " " + unit);
              System.err.println(message);
          }
      }

      -----

      ###@###.### 2002-06-26

      I observed the same crash with CompileTheWorld of admswt10.jar on windows-i386:
      java_g -hopper_baseline -Xbatch -Xss4m -XX:+CompileTheWorld -XX:MinInliningThreshold=0 -Xbootclasspath/p:admswt10.jar

      SQE, Francis Hsu, confirmed that the current hopper candidate crashes when
      running CompileTheWorld on admswt10.jar with solaris-i386.

            mpalecznsunw Michael Paleczny (Inactive)
            mmcclosksunw Michael Mccloskey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: