os::release_memory and os::uncommit_memory could fail due to: ① Bad arguments, or ② The OS encountered an issue out of control of the JVM.
①
If there is a JVM bug, it's probably reasonable to fatally fail here. Or the caller could be intentionally passing arguments that may or may not be valid. I don't think there is any code like that currently, and this is probably a bad pattern to be following anyway.
②
With regard to mmap/munmap, the only errors that aren't due to bad arguments are ENOMEM and ones related to file descriptors (which are not applicable to uncommit or release).
On Windows, VirtualFree only fails due to bad arguments.
On AIX, shmdt and disclaim64 only fail due to bad arguments. msync could spontaneously fail with EIO: "An I/O error occurred while reading from or writing to the file system."
On BSD, it seems like mprotect and madvise fail only due to bad arguments or invalid privileges.
If none of the scenarios in (2) are recoverable, then perhaps fatally failing is OK if release/uncommit memory fails.
See original discussion: https://github.com/openjdk/jdk/pull/24084#issuecomment-2752513700
①
If there is a JVM bug, it's probably reasonable to fatally fail here. Or the caller could be intentionally passing arguments that may or may not be valid. I don't think there is any code like that currently, and this is probably a bad pattern to be following anyway.
②
With regard to mmap/munmap, the only errors that aren't due to bad arguments are ENOMEM and ones related to file descriptors (which are not applicable to uncommit or release).
On Windows, VirtualFree only fails due to bad arguments.
On AIX, shmdt and disclaim64 only fail due to bad arguments. msync could spontaneously fail with EIO: "An I/O error occurred while reading from or writing to the file system."
On BSD, it seems like mprotect and madvise fail only due to bad arguments or invalid privileges.
If none of the scenarios in (2) are recoverable, then perhaps fatally failing is OK if release/uncommit memory fails.
See original discussion: https://github.com/openjdk/jdk/pull/24084#issuecomment-2752513700