1// https://github.com/google/sanitizers/issues/925
2// RUN: %clang_asan -O0 %s -o %t && %run %t 2>&1
3
4// REQUIRES: aarch64-target-arch || x86_64-target-arch || i386-target-arch || arm-target-arch || riscv64-target-arch || loongarch64-target-arch
5
6#include <assert.h>
7#include <sys/types.h>
8#include <sys/wait.h>
9#include <unistd.h>
10#include <stdio.h>
11#include <sanitizer/asan_interface.h>
12
13__attribute__((noinline, no_sanitize("address"))) void child() {
14 alignas(8) char x[100000];
15 __asan_poison_memory_region(addr: x, size: sizeof(x));
16 _exit(status: 0);
17}
18
19__attribute__((noinline, no_sanitize("address"))) void parent() {
20 alignas(8) char x[100000];
21 assert(__asan_address_is_poisoned(x + 5000) == 0);
22}
23
24int main(int argc, char **argv) {
25 if (vfork())
26 parent();
27 else
28 child();
29
30 return 0;
31}
32

source code of compiler-rt/test/asan/TestCases/Linux/vfork.cpp