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

VM crash on calling GetObjectsWithTags with last arg = null after AddCapabilitie

XMLWordPrintable

    • tiger
    • sparc
    • solaris_8
    • Verified



      Name: vsR10008 Date: 09/05/2003



      JVMTI agent crashes on GetObjectsWithTags invocation if pointer
      argument (jobject** object_result_ptr or jlong** tag_result_ptr) is
      set to NULL and the capability can_tag_objects was previosly set.

      To reproduce this bug please run on Solaris the following sh script
      (do not forget to change JDK_PATH var):

      ---- File: runme.sh ---------------------------------------------------

      JDK_PATH="/export/ld25/java/dest/jdk1.5.0-b18/solaris-sparc"

      JVMTI_H_PATH="${JDK_PATH}/include"
      CC="cc"

      echo "...creating a.c"
      cat - > a.c <<EOF
      #include <stdio.h>
      #include "jvmti.h"

      #define BAD_CODE

      static jvmtiEnv *jvmti = NULL;
      jvmtiCapabilities pcapa;
      jvmtiCapabilities capa;

      JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) {
            jvmtiError err;
            jint res;
            res = (*jvm)->GetEnv(jvm, (void **) &jvmti, JVMTI_VERSION_1_0);
            (*jvmti)->GetPotentialCapabilities(jvmti, &pcapa);
            if (!pcapa.can_tag_objects) {
                printf("Unable to tag objects\n");
                return JNI_ERR;
            }
      #ifdef BAD_CODE
            capa.can_tag_objects = 1;
      #else
            capa.can_tag_objects = 0;
      #endif
            err=(*jvmti)->AddCapabilities(jvmti, &capa);
            if(err != JVMTI_ERROR_NONE) {
                printf("Could not aquire capability.\n");
                return JNI_ERR;
            }
            printf("Loaded!\n");
            return JNI_OK;
      }


      JNIEXPORT void JNICALL
      Java_a_check(JNIEnv *env, jclass cls) {
            jvmtiError err;
            jlong tag;
            jint len;
            jobject *objr;
            jlong *tagr;
            printf("Started!\n");
            err = (*jvmti)->GetObjectsWithTags(jvmti, 1, &tag, &len, &objr, &tagr);
            printf("Checkpoint #1\n");
            err = (*jvmti)->GetObjectsWithTags(jvmti, 1, &tag, &len, NULL, &tagr);
            printf("Checkpoint #2\n");
            err = (*jvmti)->GetObjectsWithTags(jvmti, 1, &tag, &len, &objr, NULL);
            printf("Checkpoint #3\n");
            err = (*jvmti)->GetObjectsWithTags(jvmti, 1, &tag, &len, NULL, NULL);
            printf("Finished!\n");
      }

      EOF

      echo "...creating liba.so"

      ${CC} -G -KPIC -o liba.so -I${JDK_PATH}/include -I${JDK_PATH}/include/solaris -I${JVMTI_H_PATH} a.c

      echo "...creating a.java"

      cat - > a.java <<EOF
      public class a {
            native static void check();
            public static void main(String[] args) {
                System.loadLibrary("a");
                check();
            }
      }
      EOF

      echo "...creating a.class"

      ${JDK_PATH}/bin/javac -d . a.java

      echo "...running a.class"

      LD_LIBRARY_PATH=. CLASSPATH=. ${JDK_PATH}/bin/java -showversion -agentlib:a a
      --------------------------------------------------------------------------

      Output is:
      --------------------------------------------------------------------------
      ...creating a.c
      ...creating liba.so
      ...creating a.java
      ...creating a.class
      ...running a.class
      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b18)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b18, mixed mode)

      Loaded!
      Started!
      Checkpoint #1
      #
      # An unexpected error has been detected by HotSpot Virtual Machine:
      #
      # SIGSEGV (0xb) at pc=0xfe3a4bbc, pid=6849, tid=1
      #
      # Java VM: Java HotSpot(TM) Client VM (1.5.0-beta-b18 mixed mode)
      # Problematic frame:
      # V [libjvm.so+0x3a4bbc]
      #
      # An error report file with more information is saved as hs_err_pid6849.log
      #
      # If you would like to submit a bug report, please visit:
      # http://java.sun.com/cgi-bin/bugreport.cgi
      #
      Abort - core dumped
      --------------------------------------------------------------------------
      ======================================================================

            alanb Alan Bateman
            atwosunw A2 A2 (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: