summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2014-12-24 16:58:50 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2014-12-24 16:58:50 +0000
commitcb2f6d431426240bba285f5202d522e36c2e2e8d (patch)
tree64c40a4f45f35879f46d71816e8a075a21329f13
parentced288f8229fddb2b3de865bbd7a1dded7bbba22 (diff)
downloadbcm5719-llvm-cb2f6d431426240bba285f5202d522e36c2e2e8d.tar.gz
bcm5719-llvm-cb2f6d431426240bba285f5202d522e36c2e2e8d.zip
[asan] Support ASAN_ACTIVATION_OPTIONS.
This is mostly useful for testing, as the only other way of specifying activation options (Android system property) is system-wide and affects concurrently running tests. llvm-svn: 224824
-rw-r--r--compiler-rt/lib/asan/asan_activation.cc6
-rw-r--r--compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc10
2 files changed, 15 insertions, 1 deletions
diff --git a/compiler-rt/lib/asan/asan_activation.cc b/compiler-rt/lib/asan/asan_activation.cc
index 010cf319bda..0aca1cb4e86 100644
--- a/compiler-rt/lib/asan/asan_activation.cc
+++ b/compiler-rt/lib/asan/asan_activation.cc
@@ -39,6 +39,12 @@ static struct AsanDeactivatedFlags {
// Check if activation flags need to be overriden.
// FIXME: Add diagnostic to check that activation flags string doesn't
// contain any other flags.
+ if (const char *env = GetEnv("ASAN_ACTIVATION_OPTIONS")) {
+ cf.ParseFromString(env);
+ ParseFlagsFromString(&f, env);
+ }
+
+ // Override from getprop asan.options.
char buf[100];
GetExtraActivationFlags(buf, sizeof(buf));
cf.ParseFromString(buf);
diff --git a/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc b/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc
index 2280e2af03f..e5e83066b27 100644
--- a/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc
+++ b/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cc
@@ -5,11 +5,13 @@
// RUN: %clangxx_asan -O0 -DSHARED_LIB %s -fPIC -shared -o %t-so.so
// RUN: %clangxx -O0 %s -c -o %t.o
// RUN: %clangxx_asan -O0 %t.o %libdl -o %t
-// RUN: ASAN_OPTIONS=start_deactivated=1 not %run %t 2>&1 | FileCheck %s
+// RUN: ASAN_OPTIONS=start_deactivated=1,allocator_may_return_null=0 \
+// RUN: ASAN_ACTIVATION_OPTIONS=allocator_may_return_null=1 not %run %t 2>&1 | FileCheck %s
// XFAIL: arm-linux-gnueabi
// XFAIL: armv7l-unknown-linux-gnueabihf
#if !defined(SHARED_LIB)
+#include <assert.h>
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
@@ -43,12 +45,18 @@ int main(int argc, char *argv[]) {
test_malloc_shadow();
// CHECK: =5=
+ // After this line ASan is activated and starts detecting errors.
void *fn = dlsym(dso, "do_another_bad_thing");
if (!fn) {
fprintf(stderr, "dlsym failed: %s\n", dlerror());
return 1;
}
+ // Test that ASAN_ACTIVATION_OPTIONS=allocator_may_return_null=1 has effect.
+ void *p = malloc((unsigned long)-2);
+ assert(!p);
+ // CHECK: WARNING: AddressSanitizer failed to allocate 0xfff{{.*}} bytes
+
((Fn)fn)();
// CHECK: AddressSanitizer: heap-buffer-overflow
// CHECK: READ of size 1
OpenPOWER on IntegriCloud