1 // Test that SIGSEGV during leak checking does not crash the process.
2 // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
3 // REQUIRES: leak-detection
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <sys/mman.h>
7 #include <sanitizer/lsan_interface.h>
8 
9 char data[10 * 1024 * 1024];
10 
main()11 int main() {
12   void *p = malloc(10 * 1024 * 1024);
13   // surprise-surprise!
14   mprotect((void*)(((unsigned long)p + 4095) & ~4095), 16 * 1024, PROT_NONE);
15   mprotect((void*)(((unsigned long)data + 4095) & ~4095), 16 * 1024, PROT_NONE);
16   __lsan_do_leak_check();
17   fprintf(stderr, "DONE\n");
18 }
19 
20 // CHECK: Tracer caught signal 11
21 // CHECK: LeakSanitizer has encountered a fatal error
22 // CHECK: HINT: For debugging, try setting {{.*}} LSAN_OPTIONS
23 // CHECK-NOT: DONE
24