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

java.lang.ClassLoader.loadClass results in JVM crash on all platforms

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 1.2.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description



      Name: saC57035 Date: 01/16/98


      java.lang.ClassLoader.loadClass call of custom created class loader
      results in JVM crash on all platforms.
      (Core dumped on Solaris, unhandled exception on WinNT etc.)
      The bug is introduced in JDK-1.2beta3-C build whereas previous build is okay.

      This bug causes the following JCK tests to fail:

      JCK-1.0.2b .. JCK-1.2ea2:
      api/java_lang/Class/EquivClass.html#Class0603
      api/java_lang/Class/EquivClass.html#Class0604
      api/java_lang/Class/BoundValue.html#Class1605

      JCK-1.2beta2:
      api/java_lang/Class/manual.html#GetClassloader


      Below is the minimized test demonstrating the bug:
      ----------- ClassTest.java--------------------
      public class ClassTest {

        public static void main (String argv[]){
          String fname = null;
          if (argv.length == 1)
            fname = argv[0];
          else {
            System.out.println("Incorrect number of arguments passed");
            System.exit(1);
          }
          Class c = null;
          TestLoader tl = null;
          try {
            tl = new TestLoader();
          } catch(SecurityException s) {
      // code checking forSecurityManager removed for clarity
          } catch (Throwable e) {
            System.out.println("Failed: Unexpected exception thrown: "+e);
          }
          try {
            c = tl.loadClass(fname);
          } catch (ClassNotFoundException e) {
            System.out.println("Failed: "+e.toString());
          }
          System.out.println("Passed: class loaded successfully");
        }

      }

      class TestLoader extends ClassLoader {

        TestLoader() {
        }

        protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
          try {
            return findSystemClass(name);
          } catch (Throwable e) {
          }
          byte data[];
          try {
            java.io.InputStream in = (new java.net.URL(name)).openStream();
            java.io.ByteArrayOutputStream buf=new java.io.ByteArrayOutputStream();
            while (true) {
              int d=in.read();
              if (d==-1) break;
              buf.write(d);
            }
            data=buf.toByteArray();
        
            in.close();
          } catch(java.net.MalformedURLException e) {
            throw new ClassNotFoundException(e.toString());
          } catch(java.io.IOException e) {
            throw new RuntimeException(e.toString());
          }
      Class cl = defineClass(null, data, 0, data.length);
          if (resolve)
            resolveClass(cl);
          return cl;
        }

      }

      class TestClass { int i; }

      ------ Output of the test under Solaris JDK-1.2beta3-C --------
      83% javac ClassTest.java
      84% java ClassTest file://`pwd`/TestClass.class
      SIGSEGV 11* segmentation violation
          si_signo [11]: SIGSEGV 11* segmentation violation
          si_errno [0]: Error 0
          si_code [1]: SEGV_MAPERR [addr: 0x0]

      stackbase=F0000000, stackpointer=EFFFD058

      Full thread dump:
          "CachedReference sweeper" (TID:0xee300f28, sys_thread_t:0x76e68, state:CW) prio=9
      at java.lang.Object.wait(Native Method)
      at java.lang.Object.wait(Object.java:315)
      at java.lang.Runtime.waitForMemoryAdvice(Runtime.java:569)
      at java.lang.ref.CachedReference$Sweeper.run(CachedReference.java:342)
      at java.lang.Thread.run(Thread.java:490)
          "Finalizer" (TID:0xee300318, sys_thread_t:0x5ce20, state:CW) prio=8
      at java.lang.Object.wait(Native Method)
      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:86)
      at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:99)
      at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:131)
          "Reference handler" (TID:0xee3003c8, sys_thread_t:0x552f0, state:CW) prio=10
      at java.lang.Object.wait(Native Method)
      at java.lang.Object.wait(Object.java:315)
      at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:198)
          "Async Garbage Collector" (TID:0xee3001b0, sys_thread_t:0x56678, state:R) prio=1
          "Idle thread" (TID:0xee3001f8, sys_thread_t:0x4d8f0, state:R) prio=0
          "Clock" (TID:0xee3002d0, sys_thread_t:0x4d7d0, state:CW) prio=12
          "main" (TID:0xee300038, sys_thread_t:0x20a08, state:R) prio=5 *current thread*
      at java.lang.ClassLoader.defineClass0(Native Method)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:326)
      at TestLoader.loadClass(ClassTest.java:57)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:172)
      at ClassTest.main(ClassTest.java:21)
      Monitor Cache Dump:
      Registered Monitor Dump:
          utf8 hash table: <unowned>
          JNI pinning lock: <unowned>
          JNI global reference lock: <unowned>
          BinClass lock: <unowned>
          Class linking lock: <unowned>
          System class loader lock: <unowned>
          Code rewrite lock: <unowned>
          Heap 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" (0x4d7d0)
          Sbrk lock: <unowned>
          Monitor cache expansion lock: <unowned>
          Thread queue lock: <unowned>
          Monitor registry: owner "main" (0x20a08, 1 entry)
      Thread Alarm Q:
      Abort

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              sliangsunw Sheng Liang (Inactive)
              Reporter:
              savzan Stanislav Avzan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: