[NFC][AArch64] Explicitly define undefined bits for instructions (#122129)
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / Linux / atfork.cpp
blob95f05d634bfc7ec8e09c36b075e7632069d841d5
1 // RUN: %clang_hwasan -O0 %s -o %t && %run %t 2>&1
3 // REQUIRES: aarch64-target-arch || x86_64-target-arch || riscv64-target-arch
4 // REQUIRES: pointer-tagging
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>
15 void *volatile sink;
17 int 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;
33 return 0;