<br><br><div class="gmail_quote">On Wed, Aug 15, 2012 at 12:29 PM, Alexey Samsonov <span dir="ltr"><<a href="mailto:samsonov@google.com" target="_blank">samsonov@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: samsonov<br>
Date: Wed Aug 15 03:29:17 2012<br>
New Revision: 161935<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=161935&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=161935&view=rev</a><br>
Log:<br>
[ASan] port remaining output and feature tests to lit. TODO: we should in fact run most of the tests for 32/64 bits and for all optimization levels<br></blockquote><div>yes, please!  </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
Added:<br>
    compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc<br>
    compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc<br>
    compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc<br>
    compiler-rt/trunk/lib/asan/lit_tests/memcmp_test.cc<br>
    compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc<br>
    compiler-rt/trunk/lib/asan/lit_tests/sanity_check_pure_c.c<br>
    compiler-rt/trunk/lib/asan/lit_tests/sleep_before_dying.c<br>
    compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc<br>
    compiler-rt/trunk/lib/asan/lit_tests/stack-use-after-return.cc<br>
    compiler-rt/trunk/lib/asan/lit_tests/strip_path_prefix.c<br>
    compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc<br>
    compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc<br>
Modified:<br>
    compiler-rt/trunk/lib/asan/lit_tests/lit.cfg<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/global-overflow.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,19 @@<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer | FileCheck %s<br>
+<br>
+#include <string.h><br>
+int main(int argc, char **argv) {<br>
+  static char XXX[10];<br>
+  static char YYY[10];<br>
+  static char ZZZ[10];<br>
+  memset(XXX, 0, 10);<br>
+  memset(YYY, 0, 10);<br>
+  memset(ZZZ, 0, 10);<br>
+  int res = YYY[argc * 10];  // BOOOM<br>
+  // CHECK: {{READ of size 1 at 0x.* thread T0}}<br>
+  // CHECK: {{    #0 0x.* in main .*global-overflow.cc:12}}<br>
+  // CHECK: {{0x.* is located 0 bytes to the right of global variable}}<br>
+  // CHECK:   {{.*YYY.* of size 10}}<br>
+  res += XXX[argc] + ZZZ[argc];<br>
+  return res;<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/heap-overflow.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,26 @@<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer > %t.output<br>
+// RUN: FileCheck %s < %t.output<br>
+// RUN: FileCheck %s --check-prefix=CHECK-%os < %t.output<br>
+<br>
+#include <stdlib.h><br>
+#include <string.h><br>
+int main(int argc, char **argv) {<br>
+  char *x = (char*)malloc(10 * sizeof(char));<br>
+  memset(x, 0, 10);<br>
+  int res = x[argc * 10];  // BOOOM<br>
+  // CHECK: {{READ of size 1 at 0x.* thread T0}}<br>
+  // CHECK: {{    #0 0x.* in main .*heap-overflow.cc:11}}<br>
+  // CHECK: {{0x.* is located 0 bytes to the right of 10-byte region}}<br>
+  // CHECK: {{allocated by thread T0 here:}}<br>
+<br>
+  // CHECK-Linux: {{    #0 0x.* in .*malloc}}<br>
+  // CHECK-Linux: {{    #1 0x.* in main .*heap-overflow.cc:9}}<br>
+<br>
+  // CHECK-Darwin: {{    #0 0x.* in .*mz_malloc.*}}<br>
+  // CHECK-Darwin: {{    #1 0x.* in malloc_zone_malloc.*}}<br>
+  // CHECK-Darwin: {{    #2 0x.* in malloc.*}}<br>
+  // CHECK-Darwin: {{    #3 0x.* in main heap-overflow.cc:9}}<br>
+  free(x);<br>
+  return res;<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/large_func_test.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,53 @@<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer | c++filt > %t.output<br>
+// RUN: FileCheck %s < %t.output<br>
+// RUN: FileCheck %s --check-prefix=CHECK-%os < %t.output<br>
+<br>
+#include <stdlib.h><br>
+__attribute__((noinline))<br>
+static void LargeFunction(int *x, int zero) {<br>
+  x[0]++;<br>
+  x[1]++;<br>
+  x[2]++;<br>
+  x[3]++;<br>
+  x[4]++;<br>
+  x[5]++;<br>
+  x[6]++;<br>
+  x[7]++;<br>
+  x[8]++;<br>
+  x[9]++;<br>
+<br>
+  x[zero + 111]++;  // we should report this exact line<br>
+<br>
+  x[10]++;<br>
+  x[11]++;<br>
+  x[12]++;<br>
+  x[13]++;<br>
+  x[14]++;<br>
+  x[15]++;<br>
+  x[16]++;<br>
+  x[17]++;<br>
+  x[18]++;<br>
+  x[19]++;<br>
+}<br>
+<br>
+int main(int argc, char **argv) {<br>
+  int *x = new int[100];<br>
+  LargeFunction(x, argc - 1);<br>
+  delete x;<br>
+}<br>
+<br>
+// CHECK: {{.*ERROR: AddressSanitizer heap-buffer-overflow on address}}<br>
+// CHECK:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}<br>
+// CHECK: {{READ of size 4 at 0x.* thread T0}}<br>
+<br>
+// atos incorrectly extracts the symbol name for the static functions on<br>
+// Darwin.<br>
+// CHECK-Linux:  {{    #0 0x.* in LargeFunction.*large_func_test.cc:20}}<br>
+// CHECK-Darwin: {{    #0 0x.* in .*LargeFunction.*large_func_test.cc:20}}<br>
+<br>
+// CHECK: {{    #1 0x.* in main .*large_func_test.cc:36}}<br>
+// CHECK: {{0x.* is located 44 bytes to the right of 400-byte region}}<br>
+// CHECK: {{allocated by thread T0 here:}}<br>
+// CHECK: {{    #0 0x.* in operator new.*}}<br>
+// CHECK: {{    #1 0x.* in main .*large_func_test.cc:35}}<br>
<br>
Modified: compiler-rt/trunk/lib/asan/lit_tests/lit.cfg<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/lit.cfg?rev=161935&r1=161934&r2=161935&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/lit.cfg?rev=161935&r1=161934&r2=161935&view=diff</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/lit.cfg (original)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/lit.cfg Wed Aug 15 03:29:17 2012<br>
@@ -42,5 +42,12 @@<br>
   lit.fatal("Can't find symbolizer script on path %r" % symbolizer)<br>
 config.substitutions.append( ('%symbolizer', (" " + symbolizer + " " )))<br>
<br>
+# Define CHECK-%os to check for OS-dependent output.<br>
+config.substitutions.append( ('CHECK-%os', ("CHECK-" + config.host_os)))<br>
+<br>
 # Default test suffixes.<br>
 config.suffixes = ['.c', '.cc', '.cpp']<br>
+<br>
+# AddressSanitizer tests are currently supported on Linux and Darwin only.<br>
+if config.host_os not in ['Linux', 'Darwin']:<br>
+  config.unsupported = True<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/memcmp_test.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/memcmp_test.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/memcmp_test.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/memcmp_test.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/memcmp_test.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,13 @@<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer | c++filt | FileCheck %s<br>
+<br>
+#include <string.h><br>
+int main(int argc, char **argv) {<br>
+  char a1[] = {argc, 2, 3, 4};<br>
+  char a2[] = {1, 2*argc, 3, 4};<br>
+  int res = memcmp(a1, a2, 4 + argc);  // BOOM<br>
+  // CHECK: AddressSanitizer stack-buffer-overflow<br>
+  // CHECK: {{#0.*memcmp}}<br>
+  // CHECK: {{#1.*main}}<br>
+  return res;<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/null_deref.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,22 @@<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer | c++filt > %t.output<br>
+// RUN: FileCheck %s < %t.output<br>
+// RUN: FileCheck %s --check-prefix=CHECK-%os < %t.output<br>
+<br>
+__attribute__((noinline))<br>
+static void NullDeref(int *ptr) {<br>
+  ptr[10]++;<br>
+}<br>
+int main() {<br>
+  NullDeref((int*)0);<br>
+}<br>
+<br>
+// CHECK: {{.*ERROR: AddressSanitizer crashed on unknown address}}<br>
+// CHECK:   {{0x0*00028 .*pc 0x.*}}<br>
+// CHECK: {{AddressSanitizer can not provide additional info.}}<br>
+<br>
+// atos on Mac cannot extract the symbol name correctly.<br>
+// CHECK-Linux: {{    #0 0x.* in NullDeref.*null_deref.cc:8}}<br>
+// CHECK-Darwin: {{    #0 0x.* in .*NullDeref.*null_deref.cc:8}}<br>
+<br>
+// CHECK: {{    #1 0x.* in main.*null_deref.cc:11}}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/sanity_check_pure_c.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/sanity_check_pure_c.c?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/sanity_check_pure_c.c?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/sanity_check_pure_c.c (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/sanity_check_pure_c.c Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,15 @@<br>
+// Sanity checking a test in pure C.<br>
+// RUN: %clang -g -faddress-sanitizer -O2 %s -o %t<br>
+// RUN: %t 2>&1 | FileCheck %s<br>
+<br>
+// Sanity checking a test in pure C with -pie.<br>
+// RUN: %clang -g -faddress-sanitizer -O2 %s -pie -o %t<br>
+// RUN: %t 2>&1 | FileCheck %s<br>
+<br>
+#include <stdlib.h><br>
+int main() {<br>
+  char *x = (char*)malloc(10 * sizeof(char));<br>
+  free(x);<br>
+  return x[5];<br>
+  // CHECK: heap-use-after-free<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/sleep_before_dying.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/sleep_before_dying.c?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/sleep_before_dying.c?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/sleep_before_dying.c (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/sleep_before_dying.c Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,10 @@<br>
+// RUN: %clang -g -faddress-sanitizer -O2 %s -o %t<br>
+// RUN: ASAN_OPTIONS="sleep_before_dying=1" %t 2>&1 | FileCheck %s<br>
+<br>
+#include <stdlib.h><br>
+int main() {<br>
+  char *x = (char*)malloc(10 * sizeof(char));<br>
+  free(x);<br>
+  return x[5];<br>
+  // CHECK: Sleeping for 1 second<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/stack-overflow.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,13 @@<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer | FileCheck %s<br>
+<br>
+#include <string.h><br>
+int main(int argc, char **argv) {<br>
+  char x[10];<br>
+  memset(x, 0, 10);<br>
+  int res = x[argc * 10];  // BOOOM<br>
+  // CHECK: {{READ of size 1 at 0x.* thread T0}}<br>
+  // CHECK: {{    #0 0x.* in main .*stack-overflow.cc:8}}<br>
+  // CHECK: {{Address 0x.* is .* frame <main>}}<br>
+  return res;<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/stack-use-after-return.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/stack-use-after-return.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/stack-use-after-return.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/stack-use-after-return.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/stack-use-after-return.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,31 @@<br>
+// XFAIL: *<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer | c++filt | FileCheck %s<br>
+<br>
+#include <stdio.h><br>
+<br>
+__attribute__((noinline))<br>
+char *Ident(char *x) {<br>
+  fprintf(stderr, "1: %p\n", x);<br>
+  return x;<br>
+}<br>
+<br>
+__attribute__((noinline))<br>
+char *Func1() {<br>
+  char local;<br>
+  return Ident(&local);<br>
+}<br>
+<br>
+__attribute__((noinline))<br>
+void Func2(char *x) {<br>
+  fprintf(stderr, "2: %p\n", x);<br>
+  *x = 1;<br>
+  // CHECK: {{WRITE of size 1 .* thread T0}}<br>
+  // CHECK: {{    #0.*Func2.*stack-use-after-return.cc:18}}<br>
+  // CHECK: {{is located in frame <.*Func1.*> of T0's stack}}<br>
+}<br>
+<br>
+int main(int argc, char **argv) {<br>
+  Func2(Func1());<br>
+  return 0;<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/strip_path_prefix.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/strip_path_prefix.c?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/strip_path_prefix.c?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/strip_path_prefix.c (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/strip_path_prefix.c Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,12 @@<br>
+// RUN: %clang -g -faddress-sanitizer -O2 %s -o %t<br>
+// RUN: ASAN_OPTIONS="strip_path_prefix='/'" %t 2>&1 | FileCheck %s<br>
+<br>
+#include <stdlib.h><br>
+int main() {<br>
+  char *x = (char*)malloc(10 * sizeof(char));<br>
+  free(x);<br>
+  return x[5];<br>
+  // Check that paths in error report don't start with slash.<br>
+  // CHECK: heap-use-after-free<br>
+  // CHECK-NOT: #0 0x{{.*}} ({{[/].*}})<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/strncpy-overflow.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,28 @@<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer | c++filt > %t.output<br>
+// RUN: FileCheck %s < %t.output<br>
+// RUN: FileCheck %s --check-prefix=CHECK-%os < %t.output<br>
+<br>
+#include <string.h><br>
+#include <stdlib.h><br>
+int main(int argc, char **argv) {<br>
+  char *hello = (char*)malloc(6);<br>
+  strcpy(hello, "hello");<br>
+  char *short_buffer = (char*)malloc(9);<br>
+  strncpy(short_buffer, hello, 10);  // BOOM<br>
+  // CHECK: {{WRITE of size 1 at 0x.* thread T0}}<br>
+  // CHECK-Linux: {{    #0 0x.* in .*strncpy}}<br>
+  // CHECK-Darwin: {{    #0 0x.* in wrap_strncpy}}<br>
+  // CHECK: {{    #1 0x.* in main .*strncpy-overflow.cc:12}}<br>
+  // CHECK: {{0x.* is located 0 bytes to the right of 9-byte region}}<br>
+  // CHECK: {{allocated by thread T0 here:}}<br>
+<br>
+  // CHECK-Linux: {{    #0 0x.* in .*malloc}}<br>
+  // CHECK-Linux: {{    #1 0x.* in main .*strncpy-overflow.cc:11}}<br>
+<br>
+  // CHECK-Darwin: {{    #0 0x.* in .*mz_malloc.*}}<br>
+  // CHECK-Darwin: {{    #1 0x.* in malloc_zone_malloc.*}}<br>
+  // CHECK-Darwin: {{    #2 0x.* in malloc.*}}<br>
+  // CHECK-Darwin: {{    #3 0x.* in main .*strncpy-overflow.cc:11}}<br>
+  return short_buffer[8];<br>
+}<br>
<br>
Added: compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc?rev=161935&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc?rev=161935&view=auto</a><br>

==============================================================================<br>
--- compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc (added)<br>
+++ compiler-rt/trunk/lib/asan/lit_tests/use-after-free.cc Wed Aug 15 03:29:17 2012<br>
@@ -0,0 +1,35 @@<br>
+// RUN: %clang_asan -m64 -O2 %s -o %t<br>
+// RUN: %t 2>&1 | %symbolizer | c++filt > %t.output<br>
+// RUN: FileCheck %s < %t.output<br>
+// RUN: FileCheck %s --check-prefix=CHECK-%os < %t.output<br>
+<br>
+#include <stdlib.h><br>
+int main() {<br>
+  char *x = (char*)malloc(10 * sizeof(char));<br>
+  free(x);<br>
+  return x[5];<br>
+  // CHECK: {{.*ERROR: AddressSanitizer heap-use-after-free on address}}<br>
+  // CHECK:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}<br>
+  // CHECK: {{READ of size 1 at 0x.* thread T0}}<br>
+  // CHECK: {{    #0 0x.* in main .*use-after-free.cc:10}}<br>
+  // CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}<br>
+  // CHECK: {{freed by thread T0 here:}}<br>
+<br>
+  // CHECK-Linux: {{    #0 0x.* in .*free}}<br>
+  // CHECK-Linux: {{    #1 0x.* in main .*use-after-free.cc:9}}<br>
+<br>
+  // CHECK-Darwin: {{    #0 0x.* in .*mz_free.*}}<br>
+  // We override free() on Darwin, thus no malloc_zone_free<br>
+  // CHECK-Darwin: {{    #1 0x.* in wrap_free}}<br>
+  // CHECK-Darwin: {{    #2 0x.* in main .*use-after-free.cc:9}}<br>
+<br>
+  // CHECK: {{previously allocated by thread T0 here:}}<br>
+<br>
+  // CHECK-Linux: {{    #0 0x.* in .*malloc}}<br>
+  // CHECK-Linux: {{    #1 0x.* in main .*use-after-free.cc:8}}<br>
+<br>
+  // CHECK-Darwin: {{    #0 0x.* in .*mz_malloc.*}}<br>
+  // CHECK-Darwin: {{    #1 0x.* in malloc_zone_malloc.*}}<br>
+  // CHECK-Darwin: {{    #2 0x.* in malloc.*}}<br>
+  // CHECK-Darwin: {{    #3 0x.* in main .*use-after-free.cc:8}}<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br>