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

Null pointer access in JNI_CreateJavaVM

XMLWordPrintable

    • x86
    • other

      FULL PRODUCT VERSION :
      java version "1.8.0_73"
      Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
      Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 10 Home


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Visual Studio Community 2015
      Version 14.0.023107.0 D14REL
      Visual C++ 2015 00322-20000-00000-AA211

      A DESCRIPTION OF THE PROBLEM :
      Access Violation during call to JNI_CreateJavaVM. Debugger shows a stack that might also be corrupted.

      Tested with both x86 and x64 version of JDK, also tested _60 release.

      Same code works on VS 2012 Professional run on Windows 8.1

      I have a complete zip of the entire VS solution that can be provided.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Build attached project with JDK installed, run.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Created JVM.
      ACTUAL -
      Null pointer exception

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception thrown at 0x0F800282 in JNIExample.exe: 0xC0000005: Access violation reading location 0x00000000.

      If there is a handler for this exception, the program may be safely continued.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      #include <jni.h> /* where everything is defined */

      int main(int argc, char** argv) {
          JavaVM *jvm; /* denotes a Java VM */
          JNIEnv *env; /* pointer to native method interface */
          JavaVMInitArgs vm_args; /* JDK/JRE 6 VM initialization arguments */
          JavaVMOption* options = new JavaVMOption[1];
          options[0].optionString = "-Djava.class.path=/usr/lib/java";
          vm_args.version = JNI_VERSION_1_6;
          vm_args.nOptions = 1;
          vm_args.options = options;
          vm_args.ignoreUnrecognized = false;
          /* load and initialize a Java VM, return a JNI interface
          * pointer in env */
          JNI_CreateJavaVM(&jvm, (void**)&env, &vm_args);
          delete options;
          /* invoke the Main.test method using the JNI */
          jclass cls = env->FindClass("Main");
          jmethodID mid = env->GetStaticMethodID(cls, "test", "(I)V");
          env->CallStaticVoidMethod(cls, mid, 100);
          /* We are done. */
          jvm->DestroyJavaVM();

          return 0;
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: