[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / compiler-rt / test / gwp_asan / free_then_underflow.cpp
blob42f74bb8797d68652c02ebed3dad77c77ff81303
1 // REQUIRES: gwp_asan
2 // RUN: %clangxx_gwp_asan %s -o %t
3 // RUN: %expect_crash %run %t 2>&1 | FileCheck %s
5 // RUN: %clangxx_gwp_asan %s -o %t -DTOUCH_GUARD_PAGE
6 // RUN: %expect_crash %run %t 2>&1 | FileCheck %s
8 // CHECK: GWP-ASan detected a memory error
9 // CHECK: Use After Free
10 // CHECK-SAME: warning: buffer overflow/underflow detected on a free()'d allocation
11 // CHECK-SAME: at 0x{{[a-f0-9]+}} (1 byte to the left
13 #include <cstdlib>
15 #include "page_size.h"
17 int main() {
18 unsigned malloc_size = 1;
19 #ifdef TOUCH_GUARD_PAGE
20 malloc_size = pageSize();
21 #endif // TOUCH_GUARD_PAGE
22 char *Ptr = reinterpret_cast<char *>(malloc(malloc_size));
23 free(Ptr);
24 volatile char x = *(Ptr - 1);
25 return 0;