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

Missing super class causes memory fault in java VM

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.1.5
    • 1.1.4
    • hotspot
    • 1.1.5
    • x86
    • windows_nt
    • Verified



      Name: chT40241 Date: 09/19/97


      The following sample application consisting of 4 very small classes demonstrates the problem:

      1.TestCase2.java


      public class TestCase2 {
      public static void main(String args[]) throws Exception {
      try {
      Class c = Class.forName("Subclass");
      } catch(Throwable t) {
      System.out.println("Oopsie!");
      }
      Class cc = Class.forName("Subclass");
      }
      }



      2.Subclass.java


      public class Subclass extends Base {
      public int dummy() { return 0; }
      }



      3.Base.java


      public class Base extends Missing {
      public int dummy() { return 1; }
      }



      4.Missing.java


      public class Missing {
      protected int WhoCares = -1;
      }





      Reproducing the problem



      1.Compile the above classes.

      2.Remove the file Missing.class.

      3.execute the command "java TestCase2".

      The java VM will crash. It should have thrown a java.lang.NoClassDefFoundError.



      Our Analysis

      We have found the following problem in class resolution:

      When a class cannot be initialized because its superclass cannot be found, the ClassBlock is not marked in error. If another attempt is made to initialize the class, a memory fault will generally occur, because the class is not marked in error, is shown to be initialized, and has a 0 superclass field. We have corrected this problem by setting the error flag for the class block in this circumstance. The diffs for this change are given below.

      Inspection of other failures in classresolver.c reveals other places where errors are detected and exceptions thrown without marking the class block in error. These places are highly suspicious, but we have made no attempt to correct this code, or to make a more certain determination whether they also represent errors.

      Here are the diffs for the fix:


      *** d:\jdk1.1.4g\src\share\java\runtime\classresolver.c Mon Aug 25 11:02:36 1997
      --- d:\jdk1.1.4mod\src\share\java\runtime\classresolver.c Thu Sep 18 14:22:08 1997
      ***************
      *** 721,726 ****
      --- 721,727 ----
         ret = JAVAPKG "NoClassDefFoundError";
         *detail = cbSuperName(cb);
         cbSuperclass(cb) = NULL;
      + CCSet(cb, Error); // ARB SAS NoClassDefFoundError
         }
         } else if (cb == classJavaLangObject) {
         cbSuperclass(cb) = 0;

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

            apalanissunw Anand Palaniswamy (Inactive)
            chickeysunw Chuck Hickey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: