1 | // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s |
2 | // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s |
3 | |
4 | // UNSUPPORTED: darwin, aarch64 |
5 | |
6 | #include <assert.h> |
7 | #include <sys/wait.h> |
8 | #include <unistd.h> |
9 | #include <signal.h> |
10 | |
11 | int main(int argc, char **argv) { |
12 | pid_t pid = fork(); |
13 | if (pid) { // parent |
14 | int x[3]; |
15 | int *status = x + argc * 3; |
16 | int res; |
17 | |
18 | siginfo_t *si = (siginfo_t*)(x + argc * 3); |
19 | res = waitid(idtype: P_ALL, id: 0, infop: si, WEXITED | WNOHANG); |
20 | // CHECK: stack-buffer-overflow |
21 | // CHECK: {{WRITE of size .* at 0x.* thread T0}} |
22 | // CHECK: {{in .*waitid}} |
23 | // CHECK: {{in main .*waitid.cpp:}} |
24 | // CHECK: is located in stack of thread T0 at offset |
25 | // CHECK: {{in main}} |
26 | return res != -1; |
27 | } |
28 | // child |
29 | return 0; |
30 | } |
31 | |