Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-5505

[drlvm][JNI] Unable to create, destroy, create VM in the same process.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • DRLVM
    • None
    • SLES10

    Description

      The function JNI_CreateJavaVM() causes Segmentation fault if it is called after the VM has been destroyed in the same process. The following test reproduces this issue:

      #include "jni.h"

      static JavaVM * p_vm;
      static JNIEnv * p_env;

      static void vm_create() {
      JavaVMInitArgs vm_args;
      JavaVMOption options[0];

      JNI_GetDefaultJavaVMInitArgs(&vm_args);
      vm_args.options = options;
      vm_args.nOptions = 0;
      vm_args.ignoreUnrecognized = JNI_TRUE;
      vm_args.version = JNI_VERSION_1_2;

      if (JNI_CreateJavaVM(&p_vm, &p_env, &vm_args) < 0)

      { printf("Failed to create VM\n"); }

      printf("VM created\n");
      }

      static void vm_destroy() {
      if (p_vm == NULL)

      { printf("VM not created\n"); return; }

      if ((*p_vm)->DestroyJavaVM(p_vm) < 0)

      { printf("Failed to destroy VM\n"); }

      p_vm = NULL;
      p_env = NULL;
      printf("VM destroyed\n");
      }

      int main() {
      vm_create();
      vm_destroy();
      vm_create();
      return 0;
      }

      Attachments

        1. create-destroy-create.patch
          32 kB
          Pavel Pervov

        Issue Links

          Activity

            People

              mcfirst Pavel Pervov
              apavlenko Andrey Pavlenko
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: