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

REGRESSION:can't start 1.3 JVM from C shared lib loaded using "dlopen": worked i

XMLWordPrintable

    • generic, x86
    • generic, linux



      Name: yyT116575 Date: 12/12/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)

      I am trying to start the JVM using JNI, from a C shared library which is loaded
      by using the "dlopen" call by an executable called "rttsee".

      Both rttsee and shared library are linked with -lpthread.

      Here is the code snippet from the library, used for starting the JVM:

      ****************************************************************
      #define STR_JAVA_TWO_JVM "libjvm.so"

      int InitializeJVM()
      {
              void *libVM;
              BOOL bIsJavaTwo = TRUE;
              char buf[CLASSPATH_BUF_SIZE];
              jint res;
              char *rt_jvm_minheap;
              char *rt_jvm_maxheap;

              // Try Java two (1.2, 1.3) first for performance reasons
              libVM = dlopen(STR_JAVA_TWO_JVM, RTLD_LAZY);
              if (libVM == NULL) // no Java two? Try Java one
              {
                      bIsJavaTwo = FALSE;
                      libVM = dlopen(STR_JAVA_ONE_JVM, RTLD_LAZY);
              }
              if (libVM == NULL) // we're toast, no recovery possible
                      return FALSE;

              rt_jvm_minheap = (char *)getenv("RT_JVM_MINHEAP");
              rt_jvm_maxheap = (char *)getenv("RT_JVM_MAXHEAP");

              if (bIsJavaTwo)
              {
              typedef int (*func)(JavaVM**, JNIEnv**, JavaVMInitArgs*);
                  JavaVMOption options[2];
                  func fpJNI;
                  JavaVMInitArgs vm_args;
                  char rthome[MAX_PATH];
                  char minheapstr[80] = "";
                  char maxheapstr[80] = "";

                  fpJNI = dlsym(libVM, "JNI_CreateJavaVM");
                      // Create the Java 1.2 or greater JVM
                      vm_args.version = 0x00010002;
                      vm_args.options = options;
                      vm_args.nOptions = 2;
                      vm_args.ignoreUnrecognized = JNI_TRUE;
                      GetResolveClasspath(buf, CLASSPATH_BUF_SIZE, bIsJavaTwo);
                      options[0].optionString = buf;
                      strcpy(rthome, "-Drt.home=");
                      strcat(rthome, getenv("RTHOME"));
                      options[1].optionString = rthome;
                      if (rt_jvm_minheap)
                      {
                          sprintf(minheapstr, "-Xms%s", rt_jvm_minheap);
                          options[2].optionString = minheapstr;
                          vm_args.nOptions=3;
                      }
                      if (rt_jvm_maxheap)
                      {
                          sprintf(maxheapstr, "-Xmx%s", rt_jvm_maxheap);
                          options[3].optionString = maxheapstr;
                          vm_args.nOptions=4;
                      }
                      res = fpJNI(&gbJvm, &gbEnv, &vm_args);
              }
      ************************************************************************

      The Java 2 JVM library is found successfully, it's the JVM kickoff that fails.

      I am getting the folowing error:
      #
      # HotSpot Virtual Machine Error, Internal Error
      # Please report this error at
      # http://java.sun.com/cgi-bin/bugreport.cgi
      #
      # Error ID: 4F533F4C494E55580E4350500570
      #
      # Problematic Thread: rttsee: fatal program initialization error:
      [23.3.9.2]: Received SIGSEGV signal

      The link statement to make the library is:
      gcc -export -shared -lpthread -static -L../../../linux_stage/pvt/lib/rel -lrttss
       -lrtmsgc -ltmsconfiguration -lrtlogio -L/usr/lib/gcc-lib/i386-redhat-linux/egcs
      -2.91.66 -lstdc++ -lgcc -L/usr/java/jdk1.3/jre/lib/i386/client -ljvm rttseajava.o -o ../../../linux_stage/pvt/prod/rel/TSEA/rttseajava.so

      It all worked OK with sdk1.2.2, and it fails with 1.3
      (Review ID: 113522)
      ======================================================================

            sgoldman Steve Goldman (Inactive)
            yyoungsunw Yung-ching Young (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: