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

test_os_linux.cpp uses NULL instead of MAP_FAILED to check for failed mmap call

XMLWordPrintable

    • gc
    • b27

      The gtest in runtime/test_os_linux.cpp tests for a failed MMAP using != NULL instead of MAP_FAILED (which is defined as

      #define MAP_FAILED ((void *) -1)

      ) but the code uses NULL (twice):

        char* const mapping = (char*) ::mmap(NULL, mapping_size,
            PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE,
            -1, 0);
        ASSERT_TRUE(mapping != NULL) << " mmap failed, mapping_size = " << mapping_size;
        // Unmap the mapping, it will serve as a value for a "good" req_addr
        ::munmap(mapping, mapping_size);

      All other mmap uses check for MAP_FAILED manual inspection via grep shows.

      Fix this.

            tschatzl Thomas Schatzl
            tschatzl Thomas Schatzl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: