| 1 | // RUN: %clangxx_asan -O0 -mllvm -asan-instrument-dynamic-allocas %s -o %t |
| 2 | // RUN: not %run %t 2>&1 | FileCheck %s |
| 3 | // |
| 4 | // MSVC doesn't support VLAs |
| 5 | // UNSUPPORTED: msvc |
| 6 | |
| 7 | // This is reduced testcase based on Chromium code. |
| 8 | // See http://reviews.llvm.org/D6055?vs=on&id=15616&whitespace=ignore-all#toc. |
| 9 | |
| 10 | #include "defines.h" |
| 11 | #include <assert.h> |
| 12 | #include <stdint.h> |
| 13 | |
| 14 | int a = 7; |
| 15 | int b; |
| 16 | int c; |
| 17 | int *p; |
| 18 | |
| 19 | ATTRIBUTE_NOINLINE void fn3(int *first, int second) {} |
| 20 | |
| 21 | int main() { |
| 22 | int d = b && c; |
| 23 | int e[a]; |
| 24 | assert(!(reinterpret_cast<uintptr_t>(e) & 31L)); |
| 25 | int f; |
| 26 | if (d) |
| 27 | fn3(first: &f, second: sizeof 0 * (&c - e)); |
| 28 | e[a] = 0; |
| 29 | // CHECK: ERROR: AddressSanitizer: dynamic-stack-buffer-overflow on address [[ADDR:0x[0-9a-f]+]] |
| 30 | // CHECK: WRITE of size 4 at [[ADDR]] thread T0 |
| 31 | return 0; |
| 32 | } |
| 33 | |