Proposal: ModuleReferenceImpl.c to use ReleaseStringUTFChars not jvmtiDeallocate
Steve Groeger
GROEGES at uk.ibm.com
Fri Aug 25 14:59:42 UTC 2017
Hello,
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 would appreciate any feedback please, and how I would go about obtaining a sponsor and contributor
Thanks
Steve Groeger
Java Runtimes Development
IBM Hursley
IBM United Kingdom Ltd
Tel: (44) 1962 816911 Mobex: 279990 Mobile: 07718 517 129
Fax (44) 1962 816800
Lotus Notes: Steve Groeger/UK/IBM
Internet: groeges at uk.ibm.com
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU
More information about the core-libs-dev
mailing list