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

assertion failure using reflection on arrays of primitive types

XMLWordPrintable

    • 1.2alpha2
    • sparc
    • solaris_2.5
    • Not verified

      Executing the following class with "java_g" causes as assertion failure in
      all versions of 1.2 that I've tried (current workspace and all promoted builds):

      import java.lang.reflect.*;

      public class ByteArray {

          public static void main(String[] args) {
      Class c = byte[].class;
      Method[] ms = c.getDeclaredMethods();
          }
      }

      As far as I can tell, the problem is that when InitClass is called from the
      ENSURE_INITIALIZED macro in "reflect_methods" (where the assertion failure
      occurs), it doesn't properly set the "initialized" flag for primitive-type
      array classes:

          } else if (cbName(cb)[0] == SIGNATURE_ARRAY) {
              ClassClass *inner_cb =
                  cbConstantPool(cb)[CONSTANT_POOL_ARRAY_CLASS_INDEX].clazz;
              if (inner_cb) {
                  InitClass(inner_cb);
                  if (exceptionOccurred(ee)) {
                      CCSet(cb, Error);
                  } else {
                      CCSet(cb, Initialized);
                  }
              }
          } else {

      If the class is an array, it is only marked "initialized" if "inner_cb" is
      non-null, whereas with arrays of primitive types, I think that it will be
      null.

      Here is the assertion failure occurring while running with dbx, and the native
      stack frame at that point:

      Full thread dump:
          "Finalizer" (TID:0xed7003e0, sys_thread_t:0x454ec, state:CW, thread_t: t@6,
      sp:0x0, stack_bottom:0xef344000, stack_size:0x22000) prio=1
              at java.lang.Object.wait(Native Method)
              at java.lang.Ref$Queue.remove(Ref.java:98)
              at java.lang.Ref$Queue.remove(Ref.java:105)
              at java.lang.Finalizer$FinalizerThread.run(Finalizer.java:136)
          "Ref handler" (TID:0xed7001b8, sys_thread_t:0x42ae4, state:CW, thread_t: t@5
      , sp:0x0, stack_bottom:0xef374000, stack_size:0x22000) prio=10
              at java.lang.Object.wait(Native Method)
              at java.lang.Object.wait(Object.java:315)
              at java.lang.Ref$RefHandler.run(Ref.java:129)
          "SIGQUIT handler" (TID:0xed700060, sys_thread_t:0x64734, state:R, thread_t:
      t@4, sp:0x0, stack_bottom:0xef3a4000, stack_size:0x22000) prio=0
          "main" (TID:0xed700190, sys_thread_t:0x21464, state:R, thread_t: t@1, sp:0x0
      , stack_bottom:0xf0000000, stack_size:0x800000) prio=5 *current thread*
              at java.lang.Class.getMethods0(Native Method)
              at java.lang.Class.getDeclaredMethods(Class.java:550)
              at ByteArray.main(ByteArray.java:7)
       
      *** panic: "../../../../src/share/javavm/runtime/jvm.c", line 4192: assertion fa
      ilure
       
      t@1 (l@1) signal ABRT (Abort) in __lwp_kill at 0xef53890c
      __lwp_kill+0x8: bgeu,a __lwp_kill+0x1c
      Current function is sysAbort
        155 _lwp_kill(_lwp_self(), SIGABRT);
      (dbx) where
        [1] __lwp_kill(0x0, 0x6, 0xefffe9cc, 0x7efefeff, 0x81010100, 0xff00), at 0xef5
      3890c
      =>[2] sysAbort(), line 155 in "system_md.c"
        [3] panic(format = 0xef759390 ""%s", line %d: assertion failure\n", ...), line
       242 in "util.c"
        [4] reflect_methods(ee = 0x21420, cb = 0xed705008, which = 1), line 4192 in "j
      vm.c"
        [5] JVM_GetClassMethods(env = 0x21420, cls = 0x24edc, which = 1), line 612 in
      "jvm.c"
        [6] Java_java_lang_Class_getMethods0(env = 0x21420, cls = 0x24edc, which = 1),
       line 207 in "Class.c"
        [7] sysInvokeNative(0x21420, 0xef63fe60, 0x24edc, 0x2ed5a, 0x2, 0x0), at 0xef7
      50cd4
        [8] invokeJNINativeMethod(o = 0xed705008, mb = 0x2e620, args_size = 2, ee = 0x
      21420), line 359 in "classruntime.c"
        [9] invokeLazyNativeMethod(o = 0xed705008, mb = 0x2e620, args_size = 2, ee = 0
      x21420), line 488 in "classruntime.c"
        [10] ExecuteJava(initial_pc = 0xeffff538 "\x30000059", ee = 0x21420), line 171
      4 in "executeJava.c"
        [11] do_execute_java_method_vararg(ee = 0x21420, obj = 0xed705030, method_name
       = 0x5ba9c "main", method_signature = 0x5ba30 "([Ljava/lang/String;)V", mb = 0x5
      c4f8, isStaticCall = TRUE, args = 0xeffff648, otherBits = (nil), shortFloats = F
      ALSE), line 569 in "interpreter.c"
        [12] do_execute_java_method(ee = 0x21420, obj = 0xed705030, method_name = (nil
      ), signature = (nil), mb = 0x5c4f8, isStaticCall = TRUE, ...), line 401 in "inte
      rpreter.c"
        [13] java_main(argc = 0, argv = 0xeffff870), line 522 in "javai.c"
        [14] main(argc = 2, argv = 0xeffff86c, envp = 0xeffff878), line 31 in "java.c"



      And the following thread dump is produced when run from the command line:

      Full thread dump:
          "Finalizer" (TID:0xed7003e0, sys_thread_t:0x455ec, state:CW, thread_t: t@6,
      sp:0x0, stack_bottom:0xef344000, stack_size:0x22000) prio=1
              at java.lang.Object.wait(Native Method)
              at java.lang.Ref$Queue.remove(Ref.java:98)
              at java.lang.Ref$Queue.remove(Ref.java:105)
              at java.lang.Finalizer$FinalizerThread.run(Finalizer.java:136)
          "Ref handler" (TID:0xed7001b8, sys_thread_t:0x42be4, state:CW, thread_t: t@5
      , sp:0x0, stack_bottom:0xef374000, stack_size:0x22000) prio=10
              at java.lang.Object.wait(Native Method)
              at java.lang.Object.wait(Object.java:315)
              at java.lang.Ref$RefHandler.run(Ref.java:129)
          "SIGQUIT handler" (TID:0xed700060, sys_thread_t:0x64834, state:R, thread_t:
      t@4, sp:0x0, stack_bottom:0xef3a4000, stack_size:0x22000) prio=0
          "main" (TID:0xed700190, sys_thread_t:0x21464, state:R, thread_t: t@1, sp:0x0
      , stack_bottom:0xf0000000, stack_size:0x800000) prio=5 *current thread*
              at java.lang.Class.getMethods0(Native Method)
              at java.lang.Class.getDeclaredMethods(Class.java:550)
              at ByteArray.main(ByteArray.java:7)
       
      *** panic: "../../../../src/share/javavm/runtime/jvm.c", line 4192: assertion fa
      ilure
       
      SIGABRT 6* abort (generated by abort(3) routine)
          si_signo [6]: SIGABRT 6* abort (generated by abort(3) routine)
          si_errno [0]: Error 0
          si_code [-1]: SI_LWP [pid: 27479, uid: 24592]
              stackbase=F0000000, stackpointer=EFFFE360
       
      Full thread dump:
          "Finalizer" (TID:0xed7003e0, sys_thread_t:0x455ec, state:CW, thread_t: t@6,
      sp:0x0, stack_bottom:0xef344000, stack_size:0x22000) prio=1
              at java.lang.Object.wait(Native Method)
              at java.lang.Ref$Queue.remove(Ref.java:98)
              at java.lang.Ref$Queue.remove(Ref.java:105)
              at java.lang.Finalizer$FinalizerThread.run(Finalizer.java:136)
          "Ref handler" (TID:0xed7001b8, sys_thread_t:0x42be4, state:CW, thread_t: t@5
      , sp:0x0, stack_bottom:0xef374000, stack_size:0x22000) prio=10
              at java.lang.Object.wait(Native Method)
              at java.lang.Object.wait(Object.java:315)
              at java.lang.Ref$RefHandler.run(Ref.java:129)
          "SIGQUIT handler" (TID:0xed700060, sys_thread_t:0x64834, state:R, thread_t:
      t@4, sp:0x0, stack_bottom:0xef3a4000, stack_size:0x22000) prio=0
          "main" (TID:0xed700190, sys_thread_t:0x21464, state:R, thread_t: t@1, sp:0x0
      , stack_bottom:0xf0000000, stack_size:0x800000) prio=5 *current thread*
              at java.lang.Class.getMethods0(Native Method)
              at java.lang.Class.getDeclaredMethods(Class.java:550)
              at ByteArray.main(ByteArray.java:7)
      Monitor Cache Dump:
          java.lang.Object@ED7003F8/ED755C00: <unowned>
              Waiting to be notified:
                  "Finalizer"
          java.lang.Object@ED7001C8/ED755638: <unowned>
              Waiting to be notified:
                  "Ref handler"
      Registered Monitor Dump:
          JNI pinning lock: <unowned>
          JNI global reference lock: <unowned>
          BinClass lock: <unowned>
          Class loading lock: <unowned>
          Code rewrite lock: <unowned>
          Heap lock: <unowned>
          Monitor cache expansion lock: <unowned>
          Thread queue lock: <unowned>
          Monitor registry: owner "main" (0x21464, 1 entry)
      Abort (core dumped)

            nsaraiyasunw Nakul Saraiya (Inactive)
            peterjones Peter Jones (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: