diff options
author | Alexander Potapenko <glider@google.com> | 2013-05-17 15:11:26 +0000 |
---|---|---|
committer | Alexander Potapenko <glider@google.com> | 2013-05-17 15:11:26 +0000 |
commit | dd3c583211ccddf18cde7f42d7c5b4159e51a41f (patch) | |
tree | 61b32dc8a1b0a32a917cd82c65026b588ea39427 | |
parent | 14238b6c78ea13b1e58842ddaf244249d04d4225 (diff) | |
download | bcm5719-llvm-dd3c583211ccddf18cde7f42d7c5b4159e51a41f.tar.gz bcm5719-llvm-dd3c583211ccddf18cde7f42d7c5b4159e51a41f.zip |
[ASan] Make the regression test for time(NULL) Linux-specific, as it crashes on Darwin (and the problem used to occur on Linux).
Do not use zero-based shadow for the time() test.
llvm-svn: 182107
-rw-r--r-- | compiler-rt/lib/asan/lit_tests/Linux/time_null_regtest.cc | 17 | ||||
-rw-r--r-- | compiler-rt/lib/asan/lit_tests/time_interceptor.cc | 10 |
2 files changed, 20 insertions, 7 deletions
diff --git a/compiler-rt/lib/asan/lit_tests/Linux/time_null_regtest.cc b/compiler-rt/lib/asan/lit_tests/Linux/time_null_regtest.cc new file mode 100644 index 00000000000..fee20edd36d --- /dev/null +++ b/compiler-rt/lib/asan/lit_tests/Linux/time_null_regtest.cc @@ -0,0 +1,17 @@ +// RUN: %clangxx_asan -m64 -O0 %s -fsanitize-address-zero-base-shadow -pie -o %t && %t 2>&1 | %symbolize | FileCheck %s + +// A regression test for time(NULL), which caused ASan to crash in the +// zero-based shadow mode on Linux. +// FIXME: this test does not work on Darwin, because the code pages of the +// executable interleave with the zero-based shadow. + +#include <stdio.h> +#include <stdlib.h> +#include <time.h> + +int main() { + time_t t = time(NULL); + fprintf(stderr, "Time: %s\n", ctime(&t)); // NOLINT + // CHECK: {{Time: .* .* .*}} + return 0; +} diff --git a/compiler-rt/lib/asan/lit_tests/time_interceptor.cc b/compiler-rt/lib/asan/lit_tests/time_interceptor.cc index 1c9e5b1c1df..f5f2ad62b81 100644 --- a/compiler-rt/lib/asan/lit_tests/time_interceptor.cc +++ b/compiler-rt/lib/asan/lit_tests/time_interceptor.cc @@ -1,7 +1,6 @@ -// RUN: %clangxx_asan -m64 -O0 %s -fsanitize-address-zero-base-shadow -pie -o %t && %t 2>&1 | %symbolize | FileCheck %s +// RUN: %clangxx_asan -m64 -O0 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s -// Test the time() interceptor. Also includes a regression test for time(NULL), -// which caused ASan to crash in the zero-based shadow mode. +// Test the time() interceptor. #include <stdio.h> #include <stdlib.h> @@ -10,10 +9,7 @@ int main() { time_t *tm = (time_t*)malloc(sizeof(time_t)); free(tm); - time_t t = time(NULL); - fprintf(stderr, "Time: %s\n", ctime(&t)); // NOLINT - // CHECK: {{Time: .* .* .*}} - t = time(tm); + time_t t = time(tm); printf("Time: %s\n", ctime(&t)); // NOLINT // CHECK: use-after-free return 0; |