[LLVM][NVPTX] Add support for griddepcontrol instruction (#123511)
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / Linux / syscalls.cpp
blob154b6989899352a6648c15fde0fa29aeeb2a3127
1 // RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST
2 // RUN: %clangxx_hwasan -O3 %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST
3 // RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=halt_on_error=0:symbolize=0 %run %t 2>&1 | FileCheck %s --implicit-check-not=RETURN_FROM_TEST --check-prefixes=CHECK,RECOVER
5 // UNSUPPORTED: android
7 #include <assert.h>
8 #include <errno.h>
9 #include <glob.h>
10 #include <malloc.h>
11 #include <stdio.h>
12 #include <string.h>
14 #include <sanitizer/hwasan_interface.h>
15 #include <sanitizer/linux_syscall_hooks.h>
17 /* Test the presence of __sanitizer_syscall_ in the tool runtime, and general
18 sanity of their behaviour. */
20 int main(int argc, char *argv[]) {
21 // lit.cfg.py currently sets 'disable_allocator_tagging=1'
22 __hwasan_enable_allocator_tagging();
24 char *buf = (char *)malloc(1000);
25 assert(buf != NULL);
27 __sanitizer_syscall_pre_recvmsg(0, buf - 1, 0);
28 // CHECK: HWAddressSanitizer: tag-mismatch on address [[PTR:0x[a-f0-9]+]]
29 // CHECK: Cause: heap-buffer-overflow
30 // CHECK: [[PTR]] is located 1 bytes before a 1000-byte region
32 free(buf);
33 fprintf(stderr, "RETURN_FROM_TEST\n");
34 // RECOVER: RETURN_FROM_TEST
35 return 0;