RFR: 8276990: Memory leak in invoker.c fillInvokeRequest() during JDI operations
Chris Plummer
cjplummer at openjdk.java.net
Tue Feb 1 19:58:10 UTC 2022
On Tue, 1 Feb 2022 19:33:22 GMT, Roman Kennke <rkennke at openjdk.org> wrote:
>> src/jdk.jdwp.agent/share/native/libjdwp/invoker.c line 240:
>>
>>> 238: }
>>> 239: error = methodSignature(method, NULL, &request->methodSignature, NULL);
>>> 240: if (error != JVMTI_ERROR_NONE) {
>>
>> Shouldn't this be done when the invoke has completed rather than at the start of the next invoke? Otherwise you potentially have one outstanding allocation for every thread, and you still have a leak when the thread exits.
>
>> Shouldn't this be done when the invoke has completed rather than at the start of the next invoke? Otherwise you potentially have one outstanding allocation for every thread, and you still have a leak when the thread exits.
>
> Yes, perhaps. Please help me, where would be a good and reliable place to do that? Towards the end of invoker_doInvoke() ?
In `invoker_completeInvokeRequest()` this appears to be the last reference:
` jbyte returnType = methodSignature_returnTag(request->methodSignature);`
I would suggest freeing outside of the `if (!detached)` block and setting it to `NULL`. You might want to add an assert for `NULL` where you are currently freeing the pointer.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7306
More information about the serviceability-dev
mailing list