brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · 90a7fc0 Raw
31 lines · c
1// RUN: %clang_hwasan -O0 %s -o %t2// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=0          not %run %t 2>&1 | \3// RUN:     FileCheck %s --check-prefix=CRASH4// RUN: %env_hwasan_opts=malloc_bisect_left=1000,malloc_bisect_right=999         %run %t 2>&15// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=4294967295 not %run %t 2>&1 | \6// RUN:     FileCheck %s --check-prefix=CRASH7// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=4294967295,malloc_bisect_dump=1 not %run %t 2>&1 | \8// RUN:     FileCheck %s --check-prefixes=CRASH,DUMP9 10// FIXME: Recursive call into malloc from stack->Print(). Or maybe this feature11// needs to be removed. We don't use it, but it's in the hot code.12// UNSUPPORTED: internal_symbolizer13 14#include <stdlib.h>15#include <stdio.h>16#include <sanitizer/hwasan_interface.h>17 18int main() {19  __hwasan_enable_allocator_tagging();20  // DUMP: [alloc] {{.*}} 10{{$}}21  // DUMP: in main{{.*}}malloc_bisect.c22  char * volatile p = (char*)malloc(10);23  // CRASH: HWAddressSanitizer: tag-mismatch on address24  // CRASH: in main{{.*}}malloc_bisect.c25  char volatile x = p[16];26  free(p);27  __hwasan_disable_allocator_tagging();28 29  return 0;30}31