1// { dg-do run } 2// { dg-shouldfail "asan" } 3 4#include <stdlib.h> 5__attribute__((noinline)) 6static void LargeFunction(int *x, int zero) { 7 x[0]++; 8 x[1]++; 9 x[2]++; 10 x[3]++; 11 x[4]++; 12 x[5]++; 13 x[6]++; 14 x[7]++; 15 x[8]++; 16 x[9]++; 17 18 x[zero + 111]++; // we should report this exact line 19 20 x[10]++; 21 x[11]++; 22 x[12]++; 23 x[13]++; 24 x[14]++; 25 x[15]++; 26 x[16]++; 27 x[17]++; 28 x[18]++; 29 x[19]++; 30} 31volatile int one = 1; 32int main() { 33 int *x = new int[100]; 34 LargeFunction(x, one - 1); 35 delete x; 36} 37 38// { dg-output "ERROR: AddressSanitizer:? heap-buffer-overflow on address\[^\n\r]*" } 39// { dg-output "0x\[0-9a-f\]+ at pc 0x\[0-9a-f\]+ bp 0x\[0-9a-f\]+ sp 0x\[0-9a-f\]+\[^\n\r]*(\n|\r\n|\r)" } 40// { dg-output "\[^\n\r]*READ of size 4 at 0x\[0-9a-f\]+ thread T0\[^\n\r]*(\n|\r\n|\r)" } 41// { dg-output " #0 0x\[0-9a-f\]+ +(in \[^\n\r]*LargeFunction\[^\n\r]*(large-func-test-1.C:18|\[^\n\r]*:0)|\[(\]).*(\n|\r\n|\r)" } 42// { dg-output "\[^\n\r]*0x\[0-9a-f\]+ is located 44 bytes to the right of 400-byte region.*(\n|\r\n|\r)" } 43// { dg-output "\[^\n\r]*allocated by thread T0 here:\[^\n\r]*(\n|\r\n|\r)" } 44// { dg-output " #0( 0x\[0-9a-f\]+ +(in _*(interceptor_|)malloc|\[(\])\[^\n\r]*(\n|\r\n|\r)" } 45// { dg-output " #1|) 0x\[0-9a-f\]+ +(in (operator new|(wrap|)_*_Zn\[aw\]\[mj\])|\[(\])\[^\n\r]*(\n|\r\n|\r)" } 46