[compiler-rt] r224824 - [asan] Support ASAN_ACTIVATION_OPTIONS.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Wed Dec 24 08:58:50 PST 2014
Author: eugenis
Date: Wed Dec 24 10:58:50 2014
New Revision: 224824
URL: http://llvm.org/viewvc/llvm-project?rev=224824&view=rev
Log:
[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.
Modified:
compiler-rt/trunk/lib/asan/asan_activation.cc
compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc
Modified: compiler-rt/trunk/lib/asan/asan_activation.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_activation.cc?rev=224824&r1=224823&r2=224824&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_activation.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_activation.cc Wed Dec 24 10:58:50 2014
@@ -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);
Modified: compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc?rev=224824&r1=224823&r2=224824&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Posix/start-deactivated.cc Wed Dec 24 10:58:50 2014
@@ -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
More information about the llvm-commits
mailing list