15d71de26cedae3dafc17449fe0182045c0bd20e8Stephen Hines// RUN: %clang_cl_asan -O0 %s -Fe%t
22d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: not %run %t 2>&1 | FileCheck %s
32d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
42d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#include <malloc.h>
52d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
62d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesint main() {
72d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  int *x = (int*)malloc(42 * sizeof(int));
82d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  free(x);
92d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  free(x);
102d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK: AddressSanitizer: attempting double-free on [[ADDR:0x[0-9a-f]+]]
112d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK-NEXT: {{#0 .* free }}
122d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK-NEXT: {{#1 .* main .*double_free.cc}}:[[@LINE-3]]
132d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK: [[ADDR]] is located 0 bytes inside of 168-byte region
142d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK-LABEL: freed by thread T0 here:
152d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK-NEXT: {{#0 .* free }}
162d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK-NEXT: {{#1 .* main .*double_free.cc}}:[[@LINE-8]]
172d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK-LABEL: previously allocated by thread T0 here:
182d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK-NEXT: {{#0 .* malloc }}
192d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// CHECK-NEXT: {{#1 .* main .*double_free.cc}}:[[@LINE-12]]
202d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  return 0;
212d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}
22