diff options
author | Kostya Kortchinsky <kostyak@google.com> | 2018-06-15 16:45:19 +0000 |
---|---|---|
committer | Kostya Kortchinsky <kostyak@google.com> | 2018-06-15 16:45:19 +0000 |
commit | a8f6940aafd86848e846cd811cafaaa3aa0fab70 (patch) | |
tree | f8cfdab75adaeb92bf9935366c8e3ccc00402d0a /test/scudo | |
parent | e8b47a537f4c849e66e450dadddfbfe03d1f06fd (diff) |
[scudo] Add verbose failures in place of CHECK(0)
Summary:
The current `FailureHandler` mechanism was fairly opaque with regard to the
failure reason due to using `CHECK(0)`. Scudo is a bit different from the other
Sanitizers as it prefers to avoid spurious processing in its failure path. So
we just `dieWithMessage` using a somewhat explicit string.
Adapted the tests for the new strings.
While this takes care of the `OnBadRequest` & `OnOOM` failures, the next step
is probably to migrate the other Scudo failures in the same failes (header
corruption, invalid state and so on).
Reviewers: alekseyshl
Reviewed By: alekseyshl
Subscribers: filcab, mgorny, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D48199
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@334843 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/scudo')
-rw-r--r-- | test/scudo/aligned-new.cpp | 6 | ||||
-rw-r--r-- | test/scudo/memalign.c | 3 | ||||
-rw-r--r-- | test/scudo/sizes.cpp | 14 | ||||
-rw-r--r-- | test/scudo/valloc.c | 3 |
4 files changed, 16 insertions, 10 deletions
diff --git a/test/scudo/aligned-new.cpp b/test/scudo/aligned-new.cpp index ef37c9b0c..0a10ae188 100644 --- a/test/scudo/aligned-new.cpp +++ b/test/scudo/aligned-new.cpp @@ -1,6 +1,7 @@ // RUN: %clangxx_scudo -std=c++1z -faligned-allocation %s -o %t -// RUN: %run %t valid 2>&1 -// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1 +// RUN: %run %t valid 2>&1 +// RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1 +// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t invalid 2>&1 | FileCheck %s // Tests that the C++17 aligned new/delete operators are working as expected. // Currently we do not check the consistency of the alignment on deallocation, @@ -77,6 +78,7 @@ int main(int argc, char **argv) { const size_t alignment = (1U << 8) - 1; void *p = operator new(1, static_cast<std::align_val_t>(alignment), std::nothrow); + // CHECK: Scudo ERROR: invalid allocation alignment assert(!p); } diff --git a/test/scudo/memalign.c b/test/scudo/memalign.c index 694a4dad6..675f53415 100644 --- a/test/scudo/memalign.c +++ b/test/scudo/memalign.c @@ -1,6 +1,6 @@ // RUN: %clang_scudo %s -o %t // RUN: %run %t valid 2>&1 -// RUN: not %run %t invalid 2>&1 +// RUN: not %run %t invalid 2>&1 | FileCheck --check-prefix=CHECK-align %s // RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1 // RUN: not %run %t double-free 2>&1 | FileCheck --check-prefix=CHECK-double-free %s // RUN: %env_scudo_opts=DeallocationTypeMismatch=1 not %run %t realloc 2>&1 | FileCheck --check-prefix=CHECK-realloc %s @@ -66,6 +66,7 @@ int main(int argc, char **argv) if (!strcmp(argv[1], "invalid")) { // Alignment is not a power of 2. p = memalign(alignment - 1, size); + // CHECK-align: Scudo ERROR: invalid allocation alignment assert(!p); // Size is not a multiple of alignment. p = aligned_alloc(alignment, size >> 1); diff --git a/test/scudo/sizes.cpp b/test/scudo/sizes.cpp index a5e48a250..f7ccbebed 100644 --- a/test/scudo/sizes.cpp +++ b/test/scudo/sizes.cpp @@ -1,11 +1,11 @@ // RUN: %clangxx_scudo %s -lstdc++ -o %t -// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t malloc 2>&1 | FileCheck %s +// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-max // RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t malloc 2>&1 -// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t calloc 2>&1 | FileCheck %s +// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t calloc 2>&1 | FileCheck %s --check-prefix=CHECK-calloc // RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t calloc 2>&1 -// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t new 2>&1 | FileCheck %s -// RUN: %env_scudo_opts=allocator_may_return_null=1 not %run %t new 2>&1 | FileCheck %s -// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t new-nothrow 2>&1 | FileCheck %s +// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t new 2>&1 | FileCheck %s --check-prefix=CHECK-max +// RUN: %env_scudo_opts=allocator_may_return_null=1 not %run %t new 2>&1 | FileCheck %s --check-prefix=CHECK-oom +// RUN: %env_scudo_opts=allocator_may_return_null=0 not %run %t new-nothrow 2>&1 | FileCheck %s --check-prefix=CHECK-max // RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t new-nothrow 2>&1 // RUN: %run %t usable 2>&1 @@ -70,4 +70,6 @@ int main(int argc, char **argv) { return 0; } -// CHECK: allocator is terminating the process +// CHECK-max: {{Scudo ERROR: requested allocation size .* exceeds maximum supported size}} +// CHECK-oom: Scudo ERROR: allocator is out of memory +// CHECK-calloc: Scudo ERROR: calloc parameters overflow diff --git a/test/scudo/valloc.c b/test/scudo/valloc.c index a75071386..605b9c4d4 100644 --- a/test/scudo/valloc.c +++ b/test/scudo/valloc.c @@ -1,6 +1,6 @@ // RUN: %clang_scudo %s -o %t // RUN: %run %t valid 2>&1 -// RUN: not %run %t invalid 2>&1 +// RUN: not %run %t invalid 2>&1 | FileCheck %s // RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1 // UNSUPPORTED: android @@ -54,6 +54,7 @@ int main(int argc, char **argv) if (!strcmp(argv[1], "invalid")) { // Size passed to pvalloc overflows when rounded up. p = pvalloc((size_t)-1); + // CHECK: Scudo ERROR: pvalloc parameters overflow assert(!p); assert(errno == ENOMEM); errno = 0; |