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

Passing jvm debug parameters in JNI with no listening debugger causes crash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Fix
    • P4
    • tbd
    • 7u25
    • core-svc

    Description

      FULL PRODUCT VERSION :
      java version "1.7.0_25"
      Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
      Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      Program causing it:

              #include "jni.h"

              JavaVMInitArgs args;
      JavaVMOption* options = NULL;
              args.version = JNI_VERSION_1_2;
      args.nOptions = 1;
      args.options = options;
      args.ignoreUnrecognized = JNI_FALSE;
              options[0].optionString = "-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=1245";

      HINSTANCE hinstLib = LoadLibraryA(jvmdllPath);
      typedef jint (JNICALL *PtrCreateJavaVM)(JavaVM **, void **, void *);
      PtrCreateJavaVM ptrCreateJavaVM =
      (PtrCreateJavaVM)GetProcAddress(hinstLib, "JNI_CreateJavaVM");

      JNIEnv* env = NULL;
      int retCode = 0;
              retCode = ptrCreateJavaVM(&jvm, (void **)&env, &args); // <--------- returns no error code or exception, instead crashing the program fatally


      ERROR: transport error 202: connect failed: Connection refused
      ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
      JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../.
      ./../src/share/back/debugInit.c:741]
      FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_E
      RROR_TRANSPORT_INIT(197)


      REGRESSION. Last worked in version 7u25

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Create a C++ program with the above code and execute it

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      returns an integer and lets the program continue and handle the error
      ACTUAL -
      returns nothing and prints this to stdout

      ERROR: transport error 202: connect failed: Connection refused
      ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
      JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [../.
      ./../src/share/back/debugInit.c:741]
      FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_E
      RROR_TRANSPORT_INIT(197)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
              #include "jni.h"

              JavaVMInitArgs args;
      JavaVMOption* options = NULL;
              args.version = JNI_VERSION_1_2;
      args.nOptions = 1;
      args.options = options;
      args.ignoreUnrecognized = JNI_FALSE;
              options[0].optionString = "-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=1245";

      HINSTANCE hinstLib = LoadLibraryA(jvmdllPath);
      typedef jint (JNICALL *PtrCreateJavaVM)(JavaVM **, void **, void *);
      PtrCreateJavaVM ptrCreateJavaVM =
      (PtrCreateJavaVM)GetProcAddress(hinstLib, "JNI_CreateJavaVM");

      JNIEnv* env = NULL;
      int retCode = 0;
              retCode = ptrCreateJavaVM(&jvm, (void **)&env, &args); // <--------- returns no error code or exception, instead crashing the program fatally

      ---------- END SOURCE ----------

      Attachments

        Activity

          People

            Unassigned Unassigned
            mcastegr Mattis Castegren (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: