RFR: 8286431: Do not use resource array in posix mmap_attach_shared()

David Holmes dholmes at openjdk.org
Thu Oct 13 06:47:32 UTC 2022


On Thu, 13 Oct 2022 03:48:03 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> Please review this small clean up
> 
> perfMemory_posix.cpp uses a lot of explicit C heap alloc/free because the function may be called during early VM bootstrap, before ResourceMark can be used.
> 
> However, we have a single odd use of resource allocation in this file. It's supposed to work with Java exceptions. However, the code actually makes an explicitly exception check, so there's no need to do the resource alloc at all.
> 
> Also, there's no need to close the fd in case of exception.

One issue below and a suggestion.

I'm assuming we used the CHECK macro at one stage - hence the use of the RM etc.

src/hotspot/os/posix/perfMemory_posix.cpp line 1200:

> 1198:   char* filename = get_sharedmem_filename(dirname, vmid, nspid);
> 1199: 
> 1200:   // Handle the exception explicitly so we can free the strings.

Suggestion:
// We don't use CHECK as we need to free the strings even if an exception occurred.

src/hotspot/os/posix/perfMemory_posix.cpp line 1218:

> 1216:   if (fd == OS_ERR) {
> 1217:     return;
> 1218:   }

I think you still need this for the case where the file is insecure - no exception is thrown in that case.

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

Changes requested by dholmes (Reviewer).

PR: https://git.openjdk.org/jdk/pull/10686


More information about the hotspot-runtime-dev mailing list