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

Remove req_addr parameter from os::reserve_memory()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P4 P4
    • tbd
    • 9
    • hotspot
    • None
    • generic

      The "wish address" parameter (aka "req_addr") for the os::reserve_memory() API is harmful and should be removed.

      See discussion at: http://mail.openjdk.java.net/pipermail/hotspot-dev/2015-April/017823.html.

      In short, on mmap-based implementations (linux,bsd,solaris), calling os::reserve_memory() with a non-NULL wish address will trash existing mappings at that address, which is almost never what the programmer wants.

      This is not a theoretical issue: programmers tend to confuse os::reserve_memory() with os::attempt_reserve_memory_at(). Unfortunately, often this does not lead to an immediate error, because address space is sparsely populated on 64bit. But if java vm is embedded into another application which already did a number of allocations, chance to trash existing mappings increases.

      For all cases where one would want to use a wish address with os::reserve_memory, an alternative API exists. So, this parameter should be removed and code which relies on this parameter closely examined (e.g. see JDK-8077276).

            stuefe Thomas Stuefe
            stuefe Thomas Stuefe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: