1 // RUN: %clang_hwasan -O0 %s -o %t && %run %t 2>&1 2 3 // REQUIRES: aarch64-target-arch || x86_64-target-arch || riscv64-target-arch 4 // REQUIRES: pointer-tagging 5 6 #include <assert.h> 7 #include <pthread.h> 8 #include <sanitizer/hwasan_interface.h> 9 #include <stdio.h> 10 #include <stdlib.h> 11 #include <sys/types.h> 12 #include <sys/wait.h> 13 #include <unistd.h> 14 15 void *volatile sink; 16 main(int argc,char ** argv)17int main(int argc, char **argv) { 18 pthread_atfork(nullptr, nullptr, []() { 19 alarm(5); 20 sink = malloc(10); 21 }); 22 int pid = fork(); 23 if (pid) { 24 int wstatus; 25 do { 26 waitpid(pid, &wstatus, 0); 27 } while (!WIFEXITED(wstatus) && !WIFSIGNALED(wstatus)); 28 if (!WIFEXITED(wstatus) || WEXITSTATUS(wstatus)) { 29 fprintf(stderr, "abnormal exit\n"); 30 return 1; 31 } 32 } 33 return 0; 34 } 35