RFR(s) 8153711: [REDO] JDWP: Memory Leak: GlobalRefs never deleted when processing invokeMethod command
sgehwolf at redhat.com
Fri Sep 9 16:27:10 UTC 2016
Could I please get a review of the this 4th version of this fix:
It fixes a memory leak problem in the debugger as shown by the new
A bit of history to this new patch. The first version of this patch,
pushed as fix for JDK-4858370, caused regressions in
InterfaceMethodsTest, InvokeTest and OomDebugTest (part of the fix).
The cause was not holding the invoker lock when clearing the
references. A subsequent version caused deadlocks, because we were
holding the invoker lock while invoking in invoker_doInvoke().
Finally, a third version caused NPE's and asserts on Solaris. The
reason for them seems to be clearing the request->clazz and request-
>instance members *after* sending back the reply to the client. My
hypothesis is that it maybe related to the sequence of monitor_exit-
>perform IO->monitor_enter->toss references. Perhaps there is a
schedule where the response has been sent back, the next invoke starts
for the same app thread and it is just far enough along so that the
tossing of the references becomes observable by the next request.
Unfortunately, I don't have proof for this.
However, testing showed that tossing request->clazz and request-
>instance members before the IO operation prevents this assertion from
being triggered. Thus, I'm now clearing global references - the ones we
can clear before sending back the response to the client - in the same
block while still holding the invoker and event handler locks as the
rest of the operations being done in completeInvokeRequest. Once the
response has been sent to the client there are still two global
references to clear: The one for the return value and a possible
exception which might have occurred. Since they are required for
sending the response to the client we do this after it's been sent.
I think not holding the invoker lock while invoking is still a problem,
but that's being tracked in JDK-8156498.
- com/sun/jdi test-set. No regressions.
New OomDebugTest passes. Fails before.
- I haven't observed hangs or regressions in 1000 runs on
com/sun/jdi/OomDebugTest.java on Linux x86_64 release/fastdebug
- I haven't seen asserts being triggered on Solaris x86_64
fastdebug of 100 iterations of:
I believe I need a sponsor who can push this fix through JPRT once
More information about the serviceability-dev