1 // Test that leaks detected after forking without exec().
2 // RUN: %clangxx_lsan %s -o %t && not %run %t 2>&1 | FileCheck %s
3 
4 /// Fails on clang-cmake-aarch64-full (glibc 2.27-3ubuntu1.4).
5 // UNSUPPORTED: aarch64
6 
7 #include <assert.h>
8 #include <stdlib.h>
9 #include <sys/wait.h>
10 #include <unistd.h>
11 
main()12 int main() {
13   pid_t pid = fork();
14   assert(pid >= 0);
15   if (pid > 0) {
16     int status = 0;
17     waitpid(pid, &status, 0);
18     assert(WIFEXITED(status));
19     return WEXITSTATUS(status);
20   } else {
21     malloc(1337);
22     // CHECK: LeakSanitizer: detected memory leaks
23   }
24   return 0;
25 }
26 
27