summaryrefslogtreecommitdiffstats
path: root/compiler-rt
diff options
context:
space:
mode:
authorKuba Brecka <kuba.brecka@gmail.com>2015-02-22 11:12:17 +0000
committerKuba Brecka <kuba.brecka@gmail.com>2015-02-22 11:12:17 +0000
commit11bb33c78b75cbff5eca1eacb8790bd018502ceb (patch)
treee8af2ea80306f17f0ea700a7fe0f3c369cc759c0 /compiler-rt
parentbc4c42c3458edf7b75c47d3b6303462a1a5b0e4a (diff)
downloadbcm5719-llvm-11bb33c78b75cbff5eca1eacb8790bd018502ceb.tar.gz
bcm5719-llvm-11bb33c78b75cbff5eca1eacb8790bd018502ceb.zip
Fix gc-test.cc to work under higher -O levels
The gc-test.cc tries underflows of a variable up to -32 bytes, but on i386, the left redzone is not 32 bytes, it’s only 16 bytes and therefore the access to var[-32] is completely off. The reason why this test didn’t fail before is that we’ve been lucky and there was another variable before the var array, which was also instrumented. This fix uses “-32” for 64-bit systems and “-16” for 32-bit. Reviewed at http://reviews.llvm.org/D7809 llvm-svn: 230172
Diffstat (limited to 'compiler-rt')
-rw-r--r--compiler-rt/test/asan/TestCases/gc-test.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler-rt/test/asan/TestCases/gc-test.cc b/compiler-rt/test/asan/TestCases/gc-test.cc
index ffbea85b265..944590a289d 100644
--- a/compiler-rt/test/asan/TestCases/gc-test.cc
+++ b/compiler-rt/test/asan/TestCases/gc-test.cc
@@ -1,6 +1,9 @@
// RUN: %clangxx_asan %s -pthread -o %t
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0
+// RUN: %clangxx_asan -O3 %s -pthread -o %t
+// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=1 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
+// RUN: env ASAN_OPTIONS=detect_stack_use_after_return=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0
// REQUIRES: stable-runtime
#include <assert.h>
@@ -9,6 +12,7 @@
#include <sanitizer/asan_interface.h>
static const int kNumThreads = 2;
+static const int kLeftRedzoneSize = sizeof(void *) * 4;
void *Thread(void *unused) {
void *fake_stack = __asan_get_current_fake_stack();
@@ -23,7 +27,7 @@ void *Thread(void *unused) {
assert(real_stack);
assert((char*)beg <= (char*)&var[0]);
assert((char*)end > (char*)&var[0]);
- for (int i = -32; i < 15; i++) {
+ for (int i = -kLeftRedzoneSize; i < 15; i++) {
void *beg1, *end1;
char *ptr = &var[0] + i;
void *real_stack1 =
OpenPOWER on IntegriCloud