Index: lib/asan/asan_flags.h =================================================================== --- lib/asan/asan_flags.h +++ lib/asan/asan_flags.h @@ -27,6 +27,10 @@ // 4) overriden from env variable ASAN_OPTIONS. // 5) overriden during ASan activation (for now used on Android only). +#if SANITIZER_MAC +#define ASAN_DEFAULT_OPTIONS abort_on_error=1 +#endif + namespace __asan { struct Flags { Index: test/asan/TestCases/Darwin/abort_on_error-darwin.cc =================================================================== --- test/asan/TestCases/Darwin/abort_on_error-darwin.cc +++ test/asan/TestCases/Darwin/abort_on_error-darwin.cc @@ -0,0 +1,16 @@ +// Check that with empty ASAN_OPTIONS, ASan reports on OS X actually crash +// the process (abort_on_error=1). See also Linux/abort_on_error-linux.cc. + +// RUN: %clangxx_asan %s -o %t + +// Intentionally don't inherit the default ASAN_OPTIONS. +// RUN: ASAN_OPTIONS="" not --crash %run %t 2>&1 | FileCheck %s + +#include +int main() { + char *x = (char*)malloc(10 * sizeof(char)); + free(x); + return x[5]; + // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}} + // CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}} +} Index: test/asan/TestCases/Linux/abort_on_error-linux.cc =================================================================== --- test/asan/TestCases/Linux/abort_on_error-linux.cc +++ test/asan/TestCases/Linux/abort_on_error-linux.cc @@ -0,0 +1,16 @@ +// Check that with empty ASAN_OPTIONS, ASan reports on Linux don't crash +// the process (abort_on_error=0). See also Darwin/abort_on_error-darwin.cc. + +// RUN: %clangxx_asan %s -o %t + +// Intentionally don't inherit the default ASAN_OPTIONS. +// RUN: ASAN_OPTIONS="" not run %t 2>&1 | FileCheck %s + +#include +int main() { + char *x = (char*)malloc(10 * sizeof(char)); + free(x); + return x[5]; + // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}} + // CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}} +} Index: test/asan/lit.cfg =================================================================== --- test/asan/lit.cfg +++ test/asan/lit.cfg @@ -150,6 +150,7 @@ if config.host_os == 'Darwin': config.suffixes.append('.mm') + config.environment["ASAN_OPTIONS"] = "abort_on_error=0" # AddressSanitizer tests are currently supported on Linux, Darwin and # FreeBSD only.