[compiler-rt] r182107 - [ASan] Make the regression test for time(NULL) Linux-specific, as it crashes on Darwin (and the problem used to occur on Linux).
Alexander Potapenko
glider at google.com
Fri May 17 08:11:26 PDT 2013
Author: glider
Date: Fri May 17 10:11:26 2013
New Revision: 182107
URL: http://llvm.org/viewvc/llvm-project?rev=182107&view=rev
Log:
[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.
Added:
compiler-rt/trunk/lib/asan/lit_tests/Linux/time_null_regtest.cc (with props)
Modified:
compiler-rt/trunk/lib/asan/lit_tests/time_interceptor.cc
Added: compiler-rt/trunk/lib/asan/lit_tests/Linux/time_null_regtest.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/Linux/time_null_regtest.cc?rev=182107&view=auto
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/Linux/time_null_regtest.cc (added)
+++ compiler-rt/trunk/lib/asan/lit_tests/Linux/time_null_regtest.cc Fri May 17 10:11:26 2013
@@ -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;
+}
Propchange: compiler-rt/trunk/lib/asan/lit_tests/Linux/time_null_regtest.cc
------------------------------------------------------------------------------
svn:eol-style = LF
Modified: compiler-rt/trunk/lib/asan/lit_tests/time_interceptor.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/time_interceptor.cc?rev=182107&r1=182106&r2=182107&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/time_interceptor.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/time_interceptor.cc Fri May 17 10:11:26 2013
@@ -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;
More information about the llvm-commits
mailing list