RFR: 8336692: Redo fix for JDK-8284620

Vladimir Kozlov kvn at openjdk.org
Sat Jul 20 02:22:31 UTC 2024


On Sat, 20 Jul 2024 00:52:21 GMT, Dean Long <dlong 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.

I moved it outside. I only added `!= nullptr` check which may look like we still inside loop.

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

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


More information about the hotspot-compiler-dev mailing list