RFR: JDK-8263558: Possible NULL dereference in fast path arena free if ZapResourceArea is true [v5]

Thomas Stuefe stuefe at openjdk.java.net
Thu Mar 18 04:42:49 UTC 2021


On Thu, 18 Mar 2021 00:05:38 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:

>> Thomas Stuefe has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   make Arealloc and Afree behave like realloc and free
>
> src/hotspot/share/memory/arena.cpp line 368:
> 
>> 366: // Reallocate storage in Arena.
>> 367: void *Arena::Arealloc(void* old_ptr, size_t old_size, size_t new_size, AllocFailType alloc_failmode) {
>> 368:   if (new_size == 0) return NULL;
> 
> [pre-existing] Isn't this a leak?  Probably just dropping old_ptr.

Yes, it is a leak, at least if we run with UseMallocOnly. I think this, and Amalloc, should behave consistently with os::malloc here, which is to return a small non-null allocation for size=0. Basically, if size==0 size=1.

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

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


More information about the hotspot-runtime-dev mailing list