Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8286431

Do not use resource array in posix mmap_attach_shared()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • 20
    • hotspot
    • b22

      https://github.com/openjdk/jdk/blob/6a7c023796b0f39f54d0335f4723c1f06ff0032d/src/hotspot/os/posix/perfMemory_posix.cpp#L1162-L1181

      We are calling with THREAD and checking for error/exceptions explicitly. There's no need to use NEW_RESOURCE_ARRAY here

        char* filename = get_sharedmem_filename(dirname, vmid, nspid);

        // copy heap memory to resource memory. the open_sharedmem_file
        // method below need to use the filename, but could throw an
        // exception. using a resource array prevents the leak that
        // would otherwise occur.
        char* rfilename = NEW_RESOURCE_ARRAY(char, strlen(filename) + 1);
        strcpy(rfilename, filename);

        // free the c heap resources that are no longer needed
        if (luser != user) FREE_C_HEAP_ARRAY(char, luser);
        FREE_C_HEAP_ARRAY(char, dirname);
        FREE_C_HEAP_ARRAY(char, filename);

        // open the shared memory file for the give vmid
        fd = open_sharedmem_file(rfilename, file_flags, THREAD);

        if (fd == OS_ERR) {
          return;
        }

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: