RFR: 8279949: JavaThread::_free_handle_block leaks native memory

David Holmes dholmes at openjdk.java.net
Mon Feb 14 00:48:03 UTC 2022


On Sat, 12 Feb 2022 22:07:33 GMT, Leonid Mesnik <lmesnik at openjdk.org> wrote:

> Please review following fix which delete whole list of JNIHandle blocks in JNIHandleBlock::release_block(...).
> Also, I added sanity verification of _pop_frame_link to ensure that there are no leaks there.
> 
> Fix verified with tier1-6. Also, verified that memory leak is not reproduced anymore.
> 
> Thanks to Vladimir I.  for finding exact root cause of problem.

Marked as reviewed by dholmes (Reviewer).

Leonid has pointed out how the bug was introduced by JDK-8276658. Previously `release_block` would either add a chain of blocks to the thread-local freelist, or the global freelist. After JDK-8276658 it would either add a chain of blocks to the thread-local freelist or delete the first block in the chain - hence the current bug.

IIUC now, `_pop_frame_link`  if non-null, points to a completely distinct chain of blocks that was saved as part of `pushLocalFrame` and so can never point to a block which has just been deleted.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7453


More information about the hotspot-runtime-dev mailing list