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

use ReleaseStringUTFChars instead of jvmtiDeallocate to release strings

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9, 10
    • Fix Version/s: 10
    • Component/s: core-svc
    • Labels:
      None
    • Subcomponent:
    • Introduced In Version:
      9
    • Resolved In Build:
      b22

      Description

      This is a description from Steve Groeger:

      I would like to propose the change below to src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c native code so that the getName function use ReleaseStringUTFChars() to release the memory obtained using GetStringUTFChars() instead of the current jvmtiDeallocate() method.
       
      This change seems to be inline with documented use of these functions in the Oracle documentation for JNI Functions (http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html)
       
      The code as is seems to cause a potential memory leak as the memory may not be released correctly (as the correct Release/Deallocate is not being used).
       
      diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c b/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c
      --- a/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c
      +++ b/src/jdk.jdwp.agent/share/native/libjdwp/ModuleReferenceImpl.c
      @@ -57,7 +57,7 @@
          }
          (void)outStream_writeString(out, name);
          if (name != NULL) {
      - jvmtiDeallocate(name);
      + JNI_FUNC_PTR(env, ReleaseStringUTFChars)(env, namestr, name);
          }
          return JNI_TRUE;
      }
       
      I originally raised this issue on the core-libs-dev list but they recommended I raise it on this list.
      I would appreciate any feedback please, and how I would go about obtaining a sponsor and contributor
       
      Thanks
      Steve Groeger

        Attachments

          Activity

            People

            Assignee:
            sspitsyn Serguei Spitsyn
            Reporter:
            sspitsyn Serguei Spitsyn
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: