summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/MemoryTest.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2019-05-08 02:11:07 +0000
committerLang Hames <lhames@gmail.com>2019-05-08 02:11:07 +0000
commite4b4ab6d26f885f4b12624e5d375521070d8ba3d (patch)
tree96ade27def86606cec98d22008bebdcf22eafb90 /llvm/unittests/Support/MemoryTest.cpp
parent83eb9c5b588c4848a7ed08b10ad6c6fb1945eae6 (diff)
downloadbcm5719-llvm-e4b4ab6d26f885f4b12624e5d375521070d8ba3d.tar.gz
bcm5719-llvm-e4b4ab6d26f885f4b12624e5d375521070d8ba3d.zip
[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
Diffstat (limited to 'llvm/unittests/Support/MemoryTest.cpp')
-rw-r--r--llvm/unittests/Support/MemoryTest.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/unittests/Support/MemoryTest.cpp b/llvm/unittests/Support/MemoryTest.cpp
index 33cc3edb815..dc5f606688f 100644
--- a/llvm/unittests/Support/MemoryTest.cpp
+++ b/llvm/unittests/Support/MemoryTest.cpp
@@ -50,7 +50,7 @@ class MappedMemoryTest : public ::testing::TestWithParam<unsigned> {
public:
MappedMemoryTest() {
Flags = GetParam();
- PageSize = sys::Process::getPageSize();
+ PageSize = sys::Process::getPageSizeEstimate();
}
protected:
OpenPOWER on IntegriCloud