llvm-project/llvm/lib/Support/Windows
Lang Hames e4b4ab6d26 [Support] Add error handling to sys::Process::getPageSize().
This patch changes the return type of sys::Process::getPageSize to
Expected<unsigned> to account for the fact that the underlying syscalls used to
obtain the page size may fail (see below).

For clients who use the page size as an optimization only this patch adds a new
method, getPageSizeEstimate, which calls through to getPageSize but discards
any error returned and substitues a "reasonable" page size estimate estimate
instead. All existing LLVM clients are updated to call getPageSizeEstimate
rather than getPageSize.

On Unix, sys::Process::getPageSize is implemented in terms of getpagesize or
sysconf, depending on which macros are set. The sysconf call is documented to
return -1 on failure. On Darwin getpagesize is implemented in terms of sysconf
and may also fail (though the manpage documentation does not mention this).
These failures have been observed in practice when highly restrictive sandbox
permissions have been applied. Without this patch, the result is that
getPageSize returns -1, which wreaks havoc on any subsequent code that was
assuming a sane page size value.

<rdar://problem/41654857>

Reviewers: dblaikie, echristo

Subscribers: kristina, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59107

llvm-svn: 360221
2019-05-08 02:11:07 +00:00
..
COM.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DynamicLibrary.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Host.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Memory.inc [Support] MemoryBlock size should reflect the requested size 2019-03-27 10:26:21 +00:00
Mutex.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Path.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Process.inc [Support] Add error handling to sys::Process::getPageSize(). 2019-05-08 02:11:07 +00:00
Program.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RWMutex.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Signals.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ThreadLocal.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Threading.inc [llvm][Support] Provide interface to set thread priorities 2019-04-16 14:32:43 +00:00
Watchdog.inc Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
WindowsSupport.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
explicit_symbols.inc