summaryrefslogtreecommitdiff
path: root/test/scudo
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-09-14 20:34:32 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-09-14 20:34:32 +0000
commit9ff24034ff195b03df11b09ee2c55462f8489448 (patch)
tree3b8144c936827f634aa41629b29d76378b722f96 /test/scudo
parentaa753d2dffec736c1389b876a55f6390c70d8e71 (diff)
[scudo] Fix bad request handling when allocator has not been initialized
Summary: In a few functions (`scudoMemalign` and the like), we would call `ScudoAllocator::FailureHandler::OnBadRequest` if the parameters didn't check out. The issue is that if the allocator had not been initialized (eg: if this is the first heap related function called), we would use variables like `allocator_may_return_null` and `exitcode` that still had their default value (as opposed to the one set by the user or the initialization path). To solve this, we introduce `handleBadRequest` that will call `initThreadMaybe`, allowing the options to be correctly initialized. Unfortunately, the tests were passing because `exitcode` was still 0, so the results looked like success. Change those tests to do what they were supposed to. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D37853 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/scudo')
-rw-r--r--test/scudo/memalign.cpp5
-rw-r--r--test/scudo/valloc.cpp5
2 files changed, 6 insertions, 4 deletions
diff --git a/test/scudo/memalign.cpp b/test/scudo/memalign.cpp
index 72aacffd2..8757c51c7 100644
--- a/test/scudo/memalign.cpp
+++ b/test/scudo/memalign.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_scudo %s -o %t
-// RUN: %run %t valid 2>&1
-// RUN: %run %t invalid 2>&1
+// RUN: %run %t valid 2>&1
+// RUN: not %run %t invalid 2>&1
+// RUN: SCUDO_OPTIONS=allocator_may_return_null=1 %run %t invalid 2>&1
// Tests that the various aligned allocation functions work as intended. Also
// tests for the condition where the alignment is not a power of 2.
diff --git a/test/scudo/valloc.cpp b/test/scudo/valloc.cpp
index 010dac2a5..eef556f46 100644
--- a/test/scudo/valloc.cpp
+++ b/test/scudo/valloc.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_scudo %s -o %t
-// RUN: %run %t valid 2>&1
-// RUN: %run %t invalid 2>&1
+// RUN: %run %t valid 2>&1
+// RUN: not %run %t invalid 2>&1
+// RUN: SCUDO_OPTIONS=allocator_may_return_null=1 %run %t invalid 2>&1
// Tests that valloc and pvalloc work as intended.