RFR: 8336692: Redo fix for JDK-8284620

Dean Long dlong at openjdk.org
Sat Jul 20 00:54:33 UTC 2024


On Thu, 18 Jul 2024 14:39:24 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

> [JDK-8284620](https://bugs.openjdk.org/browse/JDK-8284620) tried to fix memory leak for `CodeBuffer::_overflow_arena` but I think the fix was incorrect. It created an issue when CodeBuffer expanded and we try to use information in `CodeBuffer::_overflow_arena` but it will be nulled.
> 
> CodeBuffer expansion affect only data (addresses and descriptors) associated with code and data in CodeCache where we create new CodeBlob with bigger space for code. CodeBuffer's data allocated in C heap is not affected and should not be updated.
> 
> The original code in [CodeBuffer::take_over_code_from()](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/asm/codeBuffer.cpp#L976) incorrectly copied `_overflow_arena` from [new CodeBuffer `cb`](https://github.com/openjdk/jdk/blob/master/src/hotspot/share/asm/codeBuffer.cpp#L937) where it is NULL and as result we lost pointer to allocated space. Which was the reason for memory leak.
> 
> The fix is to remove that old line in `CodeBuffer::take_over_code_from()` and undo JDK-8284620) fix.
> 
> Tested tier1-3,stress,xcomp.

src/hotspot/share/asm/codeBuffer.cpp line 139:

> 137:     cb->free_blob();
> 138:     // free any overflow storage
> 139:     delete cb->_overflow_arena;

With this change, only this->_overflow_arena will be non-null after exapdn().  In expand() we won't copy this value to the buffer in _before_expand, so we can move this delete outside the loop like before.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20236#discussion_r1685175901


More information about the hotspot-compiler-dev mailing list