1// Check that we fill malloc-ed memory correctly.
2// RUN: %clangxx_asan %s -o %t
3// RUN: %run %t | FileCheck %s
4// RUN: %env_asan_opts=max_malloc_fill_size=10:malloc_fill_byte=8 %run %t | FileCheck %s --check-prefix=CHECK-10-8
5// RUN: %env_asan_opts=max_malloc_fill_size=20:malloc_fill_byte=171 %run %t | FileCheck %s --check-prefix=CHECK-20-ab
6
7#include <stdio.h>
8int main(int argc, char **argv) {
9 // With asan allocator this makes sure we get memory from mmap.
10 static const int kSize = 1 << 25;
11 unsigned char *x = new unsigned char[kSize];
12 printf(format: "-");
13 for (int i = 0; i <= 32; i++) {
14 printf(format: "%02x", x[i]);
15 }
16 printf(format: "-\n");
17 delete [] x;
18}
19
20// CHECK: -bebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebebe-
21// CHECK-10-8: -080808080808080808080000000000000000000000000000000000000000000000-
22// CHECK-20-ab: -abababababababababababababababababababab00000000000000000000000000-
23

source code of compiler-rt/test/asan/TestCases/malloc_fill.cpp