summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Linux/leak_check_segv.cc
blob: 2a2010f7ab0fe3685c0ca8219341f2418a5d8485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Test that SIGSEGV during leak checking does not crash the process.
// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
// REQUIRES: leak-detection
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sanitizer/lsan_interface.h>

char data[10 * 1024 * 1024];

int main() {
  void *p = malloc(10 * 1024 * 1024);
  // surprise-surprise!
  mprotect((void*)(((unsigned long)p + 4095) & ~4095), 16 * 1024, PROT_NONE);
  mprotect((void*)(((unsigned long)data + 4095) & ~4095), 16 * 1024, PROT_NONE);
  __lsan_do_leak_check();
  fprintf(stderr, "DONE\n");
}

// CHECK: Tracer caught signal 11
// CHECK: LeakSanitizer has encountered a fatal error
// CHECK: HINT: For debugging, try setting {{.*}} LSAN_OPTIONS
// CHECK-NOT: DONE