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:46:54 UTC 2021


On Thu, 18 Mar 2021 00:10:13 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 369:
> 
>> 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;
>> 369:   if (old_ptr == NULL) {
> 
> If we're being consistent with realloc, probably should test this first, then for new_size == 0 (-> Afree, see above), then the rest.

You are right, I thought so too. I would prefer to handle it as I wrote above (size==0 -> size=1).

(side note, I would love to rewrite the arena coding; either that or throw it away and reuse the existing Metaspace implementation instead for Arenas/RA. Metaspaces are Arenas too, they do the same thing, but Metaspace is a lot more evolved, and I am biased toward its code quality oc :)

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

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


More information about the hotspot-runtime-dev mailing list